Skip to content
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
merged 9 commits into from
May 15, 2024

Conversation

vbaranov
Copy link
Member

@vbaranov vbaranov commented Feb 26, 2024

Motivation

Adding from_address_hash == #{address_hash} on transactions 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)

@vbaranov vbaranov force-pushed the vb-transactions-eliminate-from-query branch 2 times, most recently from 6a7ee7c to e2f1346 Compare February 26, 2024 11:12
@vbaranov vbaranov marked this pull request as draft February 26, 2024 11:13
@vbaranov vbaranov force-pushed the vb-transactions-eliminate-from-query branch from e2f1346 to 8e24396 Compare May 7, 2024 18:11
@vbaranov 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 vbaranov marked this pull request as ready for review May 7, 2024 20:25
@vbaranov vbaranov requested review from nikitosing, Qwerty5Uiop, sl1depengwyn, varasev and fedor-ivn and removed request for nikitosing and Qwerty5Uiop May 7, 2024 20:25
@vbaranov vbaranov self-assigned this May 7, 2024
apps/explorer/lib/explorer/etherscan/logs.ex Outdated Show resolved Hide resolved
apps/explorer/lib/explorer/graphql.ex Outdated Show resolved Hide resolved
apps/explorer/lib/explorer/chain/address/counters.ex Outdated Show resolved Hide resolved
@vbaranov vbaranov force-pushed the vb-transactions-eliminate-from-query branch from d56db6e to b537e2b Compare May 15, 2024 08:52
@vbaranov vbaranov requested a review from nikitosing May 15, 2024 09:22
@vbaranov vbaranov merged commit 4d4f355 into master May 15, 2024
16 checks passed
@vbaranov vbaranov deleted the vb-transactions-eliminate-from-query branch May 15, 2024 09:30
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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants