synthquestStarkNet 4h median Layer Stats
Updated 2023-12-04
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
›
⌄
select
*
, percentile_cont(.50) within group (order by blockTime) over (partition by NULL) as medianBlockTime
, percentile_cont(.50) within group (order by tps) over (partition by NULL) as medianTPS
from (
select *
, TIMESTAMPDIFF(MILLISECOND, coalesce(lag(timestamp) over (order by block_number), timestamp)::timestamp, timestamp::timestamp) / 1000 as blockTime
, case when TIMESTAMPDIFF(MILLISECOND, coalesce(lag(timestamp) over (order by block_number), timestamp)::timestamp, timestamp::timestamp) = 0 then 3 else
txs / (TIMESTAMPDIFF(MILLISECOND, coalesce(lag(timestamp) over (order by block_number), timestamp)::timestamp, timestamp::timestamp) / 1000) END as tps
from (
select DISTINCT sum(helper) over (partition by block_number) as txs
, block_number
, timestamp
--, TIMESTAMPDIFF(MILLISECOND, coalesce(lag(timestamp) over (partition by block_number order by block_number), timestamp)::timestamp, timestamp::timestamp) as time_diff
from (
select tx_hash, timestamp, block_number, 1 as helper from external.tokenflow_starknet.decoded_events
where timestamp > current_Timestamp() - interval '4 hour'
and chain_id = 'mainnet'
group by tx_hash, timestamp, block_number
order by timestamp DESC
)
)
)
Run a query to Download Data