Skip to content

Reduce DB query build overhead with shared helpers#634

Merged
pk910 merged 17 commits intoethpandaops:masterfrom
Sahil-4555:perf/db-query-helpers
Apr 14, 2026
Merged

Reduce DB query build overhead with shared helpers#634
pk910 merged 17 commits intoethpandaops:masterfrom
Sahil-4555:perf/db-query-helpers

Conversation

@Sahil-4555
Copy link
Copy Markdown
Contributor

This PR reduces DB query build overhead by centralizing placeholder construction and fork‑ID filtering into shared helpers, then applying them across hot query paths. The changes remove repeated string building and temporary slice allocations in many IN (...) filters and batch queries, while also speeding up byte‑slice map key generation for lookup maps. Benchmarks show the placeholder builder is about 4.4x faster (18,568 ns/op down to 4,169 ns/op) with much fewer allocations (131 to 37), and byte‑slice key conversion is about 1.7x faster (209 ns/op down to 121 ns/op). Overall, the query assembly paths are now leaner and faster, especially when filters include large ID lists.

@Sahil-4555 Sahil-4555 force-pushed the perf/db-query-helpers branch from 336aa65 to e2eef96 Compare April 14, 2026 09:28
@Sahil-4555 Sahil-4555 force-pushed the perf/db-query-helpers branch from e2eef96 to 8740b7d Compare April 14, 2026 09:39
@pk910
Copy link
Copy Markdown
Member

pk910 commented Apr 14, 2026

Heya @Sahil-4555
Looks all good :) I'll gonna accept it as it simplifies the code structure for db queries too.
But in general I'd like to avoid heavy optimization only changes in dora.
I'm pretty sure there is a lot to optimize, but given the complexity of some code parts, I'd like to keep it readable and structured as is for maintainablility.

@pk910 pk910 merged commit 1dcd325 into ethpandaops:master Apr 14, 2026
4 checks passed
@Sahil-4555 Sahil-4555 deleted the perf/db-query-helpers branch April 14, 2026 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants