Skip to content

Commit 69a6e59

Browse files
authored
Merge pull request #1468 from input-output-hk/erikd/epoch-table-query
doc/interesting-queries.md: Add new query
2 parents afc7c4b + c431ae2 commit 69a6e59

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

doc/interesting-queries.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,24 @@ select distinct on(block.hash) block.hash as block_hash , epoch_no, tx_count, po
608608
stake1u9ylzsgxaa6xctf4juup682ar3juj85n8tx3hthnljg47zctvm3rc | pool1pu5jlj4q9w9jlxeu370a3c9myx47md5j5m2str0naunn2q3lkdy | 210 | | | 1 | 2020-07-29 22:41:31
609609
stake1u8mt5gqclkq0swmvzx9lvq4jgwsnx9yh030yrxwqwllu0mq2m0l4n | pool1qqqqzyqf8mlm70883zht60n4q6uqxg4a8x266sewv8ad2grkztl | 317 | pool1qqqz9vlskay2gv3ec5pyck8c2tq9ty7dpfm60x8shvapguhcemt | 211 | 3 | 2020-08-06 20:00:11
610610
```
611+
612+
### Find all incorrect entries in `epoch` table
613+
614+
In [issue #1457](https://github.com/input-output-hk/cardano-db-sync/issues/1457) it was pointed out
615+
that some entries in the epoch table were incorrect. These incorrect entries can be found using:
616+
```
617+
select b.epoch_no, e.epoch_blk_count, e.epoch_tx_count, b.block_block_count, b.block_tx_count
618+
from
619+
(select no, blk_count as epoch_blk_count, tx_count as epoch_tx_count from epoch) as e,
620+
(select epoch_no, count (block_no) as block_block_count, sum (tx_count) as block_tx_count
621+
from block group by epoch_no) as b
622+
where e.no = b.epoch_no
623+
and (e.epoch_blk_count != b.block_block_count or e.epoch_tx_count != b.block_tx_count)
624+
order by b.epoch_no ;
625+
```
626+
There is a shell script in the above issue which finds all incorrect rows in that table and fixes
627+
them.
628+
611629
---
612630

613631

0 commit comments

Comments
 (0)