Skip to content

Commit

Permalink
stop filtering by timestamp to improve new txns query performance
Browse files Browse the repository at this point in the history
  • Loading branch information
bragov4ik committed Dec 9, 2024
1 parent bde9120 commit 37a9d86
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions stats/stats/src/charts/lines/new_txns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ impl StatementFromRange for NewTxnsStatement {
range: Option<Range<DateTime<Utc>>>,
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,
Expand All @@ -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;
"#,
Expand All @@ -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;
"#,
Expand Down

0 comments on commit 37a9d86

Please sign in to comment.