TheLaughingManhourly - block_time/gas util
Updated 2025-03-03
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
›
⌄
-- forked from hourly - block_metrics @ https://flipsidecrypto.xyz/studio/queries/6c739909-37ff-40b3-8d8f-62fd9e460f46
with base as (
SELECT
block_timestamp
, block_number
, tx_count
, gas_used
, gas_limit
, lag(block_timestamp) OVER (order by block_number ASC) as p_block_timestamp
from monad.testnet.fact_blocks
WHERE 1=1
AND block_timestamp>='2025-02-19'
)
SELECT
date_trunc('hour', block_timestamp) as dhour
, COUNT(*) as blocks
, AVG(DATEDIFF('seconds', p_block_timestamp, block_timestamp)) as block_time_avg
, (60*60)/ COUNT(*) as block_time
-- these are actually stupid to do
-- , MEDIAN(DATEDIFF('seconds', p_block_timestamp, block_timestamp)) as block_time_median
-- , MODE(DATEDIFF('seconds', p_block_timestamp, block_timestamp)) as block_time_mode
-- only include non-empty blocks for gas_util perc stats
, AVG(CASE WHEN tx_count!=0 THEN ROUND((gas_used/gas_limit)*100, 2) ELSE NULL END) as gas_utilization_perc
from base
GROUP BY 1
having block_time_avg!=block_time
ORDER BY dhour ASC
QueryRunArchived: QueryRun has been archived