Skip to content

Commit a9580fe

Browse files
committed
DB Sync queries to measure slot gaps between blocks
1 parent 829b776 commit a9580fe

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

analysis/mainnet-gaps.sql

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
-- DB Sync queries to measure the number of slots between consecutive blocks.
2+
3+
-- Tally gap distribution for past year.
4+
select
5+
sum(case when gap_size > 5 * 60 then observations else 0 end) as "Gaps longer than 5 minutes"
6+
, sum(case when gap_size between 4 * 60 and 5 * 60 - 1 then observations else 0 end) as "Gaps between 4 and 5 minutes"
7+
, sum(case when gap_size between 3 * 60 and 4 * 60 - 1 then observations else 0 end) as "Gaps between 3 and 4 minutes"
8+
, sum(case when gap_size between 2 * 60 and 3 * 60 - 1 then observations else 0 end) as "Gaps between 2 and 3 minutes"
9+
, sum(case when gap_size between 1 * 60 and 2 * 60 - 1 then observations else 0 end) as "Gaps between 1 and 2 minutes"
10+
, sum(case when gap_size < 1 * 60 then observations else 0 end) as "Gaps less than 1 minute"
11+
from (
12+
select
13+
gap_size
14+
, count(*) as observations
15+
from (
16+
select
17+
slot_no
18+
, slot_no - lag(slot_no) over (order by slot_no) as gap_size
19+
from
20+
block
21+
where
22+
epoch_no between 550 - 365 / 5 and 550
23+
) gaps
24+
group by gap_size
25+
) histogram
26+
;
27+
28+
-- List largest gaps in past year.
29+
select
30+
slot_no
31+
, slot_no - lag(slot_no) over (order by slot_no) as gap_size
32+
from
33+
block
34+
where
35+
epoch_no between 550 - 365 / 5 and 550
36+
order by gap_size desc
37+
limit 10
38+
;
39+
40+
-- List largest gaps ever.
41+
select
42+
slot_no
43+
, slot_no - lag(slot_no) over (order by slot_no) as gap_size
44+
from
45+
block
46+
order by gap_size desc
47+
limit 10
48+
;

0 commit comments

Comments
 (0)