From 37a9d86208d4657eddd42845a15440d80243f8a3 Mon Sep 17 00:00:00 2001 From: Kirill Ivanov Date: Mon, 9 Dec 2024 16:56:34 +0900 Subject: [PATCH] stop filtering by timestamp to improve new txns query performance --- stats/stats/src/charts/lines/new_txns.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stats/stats/src/charts/lines/new_txns.rs b/stats/stats/src/charts/lines/new_txns.rs index 2f3b3fd26..5526050cf 100644 --- a/stats/stats/src/charts/lines/new_txns.rs +++ b/stats/stats/src/charts/lines/new_txns.rs @@ -35,6 +35,9 @@ impl StatementFromRange for NewTxnsStatement { range: Option>>, completed_migrations: &BlockscoutMigrations, ) -> Statement { + // do not filter by `!= to_timestamp(0)` because + // 1. it allows to use index `transactions_block_consensus_index` + // 2. there is no reason not to count genesis transactions if completed_migrations.denormalization { sql_with_range_filter_opt!( DbBackend::Postgres, @@ -44,7 +47,6 @@ impl StatementFromRange for NewTxnsStatement { COUNT(*)::TEXT as value FROM transactions t WHERE - t.block_timestamp != to_timestamp(0) AND t.block_consensus = true {filter} GROUP BY date; "#, @@ -62,7 +64,6 @@ impl StatementFromRange for NewTxnsStatement { FROM transactions t JOIN blocks b ON t.block_hash = b.hash WHERE - b.timestamp != to_timestamp(0) AND b.consensus = true {filter} GROUP BY date; "#,