Skip to content

Commit

Permalink
added indexes and removed aggregate functions
Browse files Browse the repository at this point in the history
added indexes to btc_blocks_can materialized view, no longer using aggregate functions
  • Loading branch information
ClaytonNorthey92 committed Aug 26, 2024
1 parent f831628 commit 1b5a7f3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions database/bfgd/postgres/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ import (
)

const (
bfgdVersion = 8
bfgdVersion = 9

logLevel = "INFO"
verbose = false
)

const effectiveHeightSql = `
COALESCE((SELECT MIN(height)
COALESCE((SELECT height
FROM
(
Expand All @@ -38,6 +38,7 @@ const effectiveHeightSql = `
= pop_basis.l2_keystone_abrev_hash
WHERE ll.l2_block_number >= l2_keystones.l2_block_number
ORDER BY height ASC LIMIT 1
)), 0)
`

Expand Down Expand Up @@ -808,7 +809,7 @@ func (p *pgdb) L2BTCFinalityByL2KeystoneAbrevHash(ctx context.Context, l2Keyston
l2_keystones.ep_hash,
l2_keystones.version,
%s,
COALESCE((SELECT MAX(height) FROM btc_blocks_can),0)
COALESCE((SELECT height FROM btc_blocks_can ORDER BY height DESC LIMIT 1),0)
FROM l2_keystones
LEFT JOIN pop_basis ON l2_keystones.l2_keystone_abrev_hash
Expand Down

0 comments on commit 1b5a7f3

Please sign in to comment.