primo_datanear_performance_agg
    Updated 2023-04-23
    --- How does NEAR stock up to other L1s in terms of speed and performance?
    --- How fast is NEAR, and compare it with other blockchain speeds in terms of transactions per minute and percentage of transactions that fail.

    -- https://app.flipsidecrypto.com/dashboard/solana-tps-TEcObr
    -- https://app.flipsidecrypto.com/dashboard/solana-tps-QynVnR

    select
    chain
    , sum(txns_total_ct) tx_total_ct
    , sum(txn_failures_ct) tx_failures_ct
    , (sum(txns_total_ct) / ({{last_n_days}}*1440)) tpm
    , (sum(txn_failures_ct) / sum(txns_total_ct)) * 100 txn_failures_pct
    from
    (
    select *
    from
    (
    select 'NEAR' chain
    , count(distinct (case when TX_STATUS != 'Success' then tx_hash else null end)) txn_failures_ct
    , count(distinct tx_hash) txns_total_ct
    from near.core.fact_transactions
    where date(block_timestamp) >current_date - {{last_n_days}} - 1
    and date(block_timestamp) < current_date
    )
    union all
    (
    select 'Solana' chain
    , count(distinct (case when succeeded = FALSE then tx_id else NULL end)) txn_failures_ct
    , count(distinct tx_id) txns_total_ct
    from solana.core.fact_transactions
    where date(block_timestamp) >current_date - {{last_n_days}} - 1
    and date(block_timestamp) < current_date
    group by 1
    )
    union all
    (
    Run a query to Download Data