-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Eliminate from_address_hash == #{address_hash} clause for transactions query in case of smart-contracts #9469
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vbaranov
force-pushed
the
vb-transactions-eliminate-from-query
branch
2 times, most recently
from
February 26, 2024 11:12
6a7ee7c
to
e2f1346
Compare
vbaranov
force-pushed
the
vb-transactions-eliminate-from-query
branch
from
May 7, 2024 18:11
e2f1346
to
8e24396
Compare
vbaranov
changed the title
Eliminate from_address_hash == #{address_hash} clause for transactions query in case of smart-contracts
fix: Eliminate from_address_hash == #{address_hash} clause for transactions query in case of smart-contracts
May 7, 2024
vbaranov
requested review from
nikitosing,
Qwerty5Uiop,
sl1depengwyn,
varasev and
fedor-ivn
and removed request for
nikitosing and
Qwerty5Uiop
May 7, 2024 20:25
nikitosing
reviewed
May 14, 2024
…query in case of smart-contracts
Co-authored-by: Kirill Fedoseev <kirill@blockscout.com>
vbaranov
force-pushed
the
vb-transactions-eliminate-from-query
branch
from
May 15, 2024 08:52
d56db6e
to
b537e2b
Compare
k1rill-fedoseev
approved these changes
May 15, 2024
nikitosing
reviewed
May 15, 2024
fedor-ivn
added a commit
that referenced
this pull request
May 18, 2024
* master: (65 commits) fix: Add healthcheck endpoints for indexer-only setup (#10076) 6.6.0 fix: Rework revert_reason (#9212) fix: Eliminate from_address_hash == #{address_hash} clause for transactions query in case of smart-contracts (#9469) feat: Add optional retry of NFT metadata fetch in Indexer.Fetcher.Tok… (#10036) fix: Separate indexer setup (#10032) feat: Blueprint contracts support (#10058) chore: Update hackney pool size: add new fetchers accounting (#9941) fix: Disallow batched queries in GraphQL endpoint (#10050) feat: Clone with immutable arguments proxy pattern (#10039) fix: vyper contracts re-verificaiton (#10053) refactor: Refactor get_additional_sources/4 -> get_additional_sources/3 (#10046) chore: Bump credo from 1.7.5 to 1.7.6 (#10060) chore: Bump redix from 1.5.0 to 1.5.1 (#10059) chore: Bump ex_doc from 0.32.1 to 0.32.2 (#10061) fix: Fix Unknown UID bug at smart-contract verification (#9986) refactor: test database config (#9662) chore: remove `has_methods` from `/addresses` (#10051) feat: Improve retry NFT fetcher (#10027) chore: Add support of Blast-specific L1 OP withdrawal events (#10049) ...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Adding
from_address_hash == #{address_hash}
ontransactions
table is redundant in case of smart-contracts. In some cases it can lead to long query execution.Changelog
Before sending query to the DB we should properly propose where clauses: we should eliminate
from_address_hash == #{address_hash}
where clause for smart-contracts and leave it as is for EOAs. Since smart-contracts cannot be originators of transactions, there are no records satisfying this where clause in case of smart-contract address. Leaving this clause for smart-contracts leads to sequential scan of the whole token transfers table, which leads to long execution time of the original query.Checklist for your Pull Request (PR)
CHANGELOG.md
with this PRmaster
in the Version column. Changes will be reflected in this table: https://docs.blockscout.com/for-developers/information-and-settings/env-variables.