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

Support efficient query for related account with method filter #897

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ptrus
Copy link
Member

@ptrus ptrus commented Jan 23, 2025

Fixes: #896

  • Promote 'likely_native_transfer' to a first-class database field
  • Denormalize 'method' and 'likely_native_transfer' to create efficient indexes for account filtering

Note: The migrations will likely take multiple hours Before this is released and deployed, it would be good to have "Nexus Blue " ready so that we can switch Nexus backend explorer uses during the update.

@ptrus ptrus changed the title Ptrus/feature/related txs denom Support efficient query for related account with method filter Jan 23, 2025
@ptrus ptrus force-pushed the ptrus/feature/related-txs-denom branch 2 times, most recently from 35a0bc7 to 61c160b Compare January 29, 2025 07:22
@ptrus ptrus force-pushed the ptrus/feature/related-txs-denom branch from 61c160b to d1e1d73 Compare February 14, 2025 08:24
@ptrus ptrus marked this pull request as ready for review February 14, 2025 08:24
Copy link
Collaborator

@pro-wh pro-wh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait where does this go relative to the related accounts change?

end_block INT;
max_block INT;
affected_rows INT;
BEGIN
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some of this stuff seems to be in the wrong commit?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

@ptrus
Copy link
Member Author

ptrus commented Feb 17, 2025

where does this go relative to the related accounts change?

The related accounts change (#809) was only for the events tables. Transactions tables already had related accounts split out in a separate table, so no changes were needed in #809.

This PR only deals with transaction tables. We denomralize some fields so that we can have more efficient indexes for the combination of related accounts + method filters. These filters are not needed for the events tables at this time, so no changes there.

@ptrus ptrus force-pushed the ptrus/feature/related-txs-denom branch 5 times, most recently from ce7f74f to 8151721 Compare February 17, 2025 09:50
@ptrus ptrus force-pushed the ptrus/feature/related-txs-denom branch from 8151721 to f1b94db Compare February 18, 2025 08:29
@ptrus ptrus requested a review from pro-wh February 18, 2025 11:35
Comment on lines +84 to +87
CREATE INDEX ix_runtime_related_transactions_address_method_round ON chain.runtime_related_transactions (runtime, account_address, method, tx_round, tx_index);
CREATE INDEX ix_runtime_related_transactions_address_native_transfer_round ON chain.runtime_related_transactions (runtime, account_address, likely_native_transfer, tx_round, tx_index);
-- This combination is needed, since explorer needs to obtain evm.Call's which are not native transfers.
CREATE INDEX ix_runtime_related_transactions_address_method_native_transfer_round ON chain.runtime_related_transactions (runtime, account_address, method, likely_native_transfer, tx_round, tx_index);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want tx_round DESC here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be equivalent either way, with the preceding fields only filtered by equality

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.

Support efficient query for related account with method filter
3 participants