primo_dataPolygon Block Performance - Daily
    Updated 2022-10-13
    --What is the average time between blocks on Polygon?
    --What was the maximum and minimum recorded time between two blocks?
    --How many transactions are done in a block on average?
    --How do these numbers compare to L1 such as Flow or Solana, or other L2 such as Arbitrum or Optimism?

    select *
    from
    (
    select *
    from
    (
    select chain, date(block_timestamp) dt, count(distinct block_number) block_ct, avg(block_time) avg_block_time, min(block_time) min_block_time, max(block_time) max_block_time, sum(tx_count) tx_ct, avg(tx_count) avg_tx_ct
    FROM
    (
    select 'polygon' chain
    , block_timestamp
    , block_number
    , lag(block_timestamp) over (order by block_timestamp) prev_block_timestamp
    , datediff(milliseconds, lag(block_timestamp) over (order by block_timestamp), block_timestamp)/1000 as block_time
    , tx_count
    from polygon.core.fact_blocks
    where date(block_timestamp) >= date('{{start_date}}')
    and date(block_timestamp) <= date('{{end_date}}')
    order by 2 asc
    )
    where prev_block_timestamp is not null
    group by 1,2
    order by 2 asc
    )
    union all
    (
    select chain, date(block_timestamp) dt, count(distinct block_number) block_ct, avg(block_time) avg_block_time, min(block_time) min_block_time, max(block_time) max_block_time, sum(tx_count) tx_ct, avg(tx_count) avg_tx_ct
    FROM
    (
    select 'ethereum' chain
    , block_timestamp
    Run a query to Download Data