From 1b5a7f332d6dccf7fb330adc3c7f9585430a86cc Mon Sep 17 00:00:00 2001 From: ClaytonNorthey92 Date: Mon, 26 Aug 2024 17:31:18 -0400 Subject: [PATCH] added indexes and removed aggregate functions added indexes to btc_blocks_can materialized view, no longer using aggregate functions --- database/bfgd/postgres/postgres.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/database/bfgd/postgres/postgres.go b/database/bfgd/postgres/postgres.go index 8b8c576c..a1dc51d1 100644 --- a/database/bfgd/postgres/postgres.go +++ b/database/bfgd/postgres/postgres.go @@ -20,14 +20,14 @@ import ( ) const ( - bfgdVersion = 8 + bfgdVersion = 9 logLevel = "INFO" verbose = false ) const effectiveHeightSql = ` - COALESCE((SELECT MIN(height) + COALESCE((SELECT height FROM ( @@ -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) ` @@ -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