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

storage/consensus: Update indexes to better serve the related accounts queries #890

Merged
merged 3 commits into from
Jan 20, 2025

Conversation

ptrus
Copy link
Member

@ptrus ptrus commented Jan 19, 2025

Fixes/mitigations for:

Fixes:

The ix_transactions_method_height was missing the tx_index, so the query optimizer didn't do the top-n optimization for consensus related accounts query with filters on method. The indexes on both tables now match on the fields and ordering, so this should be fixed.

For the https://nexus.oasis.io/v1/consensus/accounts/oasis1qrg3zwe9gvkvs6dvrytr3dedyyjyxp6kgv8u2m2m counting the huge number of related transactions appears to be problematic:

AccountStats = `
SELECT
COUNT(*)
FROM chain.accounts_related_transactions
WHERE account_address = $1::text`
hopefully the increased timeout fixes this. Otherwise we should probably move this computation into the accounts_list view, and fetch it from there.

The last query is using the indexes as expected, it just takes long due the table being huge. Hopefully, the increased timeout helps. In future we should check if there's any db setting optimizations to be done.

@ptrus ptrus force-pushed the ptrus/feature/related-txs-idx branch 2 times, most recently from fba9b10 to bfd8eb5 Compare January 19, 2025 14:58
@csillag
Copy link
Contributor

csillag commented Jan 20, 2025

I see you found a solution that will also work with multi value later. Very nice.

@ptrus ptrus force-pushed the ptrus/feature/related-txs-idx branch from b65bbd2 to 97367ae Compare January 20, 2025 13:31
@ptrus ptrus force-pushed the ptrus/feature/related-txs-idx branch from 97367ae to 17c7649 Compare January 20, 2025 14:26
@ptrus ptrus merged commit 2ad2bf3 into main Jan 20, 2025
16 checks passed
@ptrus ptrus deleted the ptrus/feature/related-txs-idx branch January 20, 2025 14:32
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