adriaparcerisasAverage time per block on Polygon
    Updated 2022-07-25
    -- 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?

    WITH
    blocks as (
    select
    block_number,
    min(block_timestamp) as block_debut,
    LAG(block_debut,1) IGNORE NULLS OVER (ORDER BY block_number) as last_block_time
    from polygon.core.fact_transactions
    where block_timestamp>=CURRENT_DATE-INTERVAL '1 MONTH' and status='SUCCESS'
    group by 1
    --order by 1 asc
    ),
    times as (
    SELECT
    block_number,
    block_debut,
    datediff('second',last_block_time,block_debut) as time_between_blocks_in_sec
    from blocks
    )
    SELECT
    trunc(block_debut,'day') as date,
    avg(time_between_blocks_in_sec) as avg_time_per_block_in_sec,
    max(time_between_blocks_in_sec) as max_time_per_block_in_sec,
    min(time_between_blocks_in_sec) as min_time_per_block_in_sec
    from times
    group by 1
    order by 1 asc
    Run a query to Download Data