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

feat: introduced an index on transactions to speed up sorting by block_timestamp and index_in_chunk #139

Merged
merged 1 commit into from
Aug 3, 2021

Conversation

telezhnaya
Copy link
Contributor

@telezhnaya telezhnaya commented Aug 2, 2021

Resolves #135

To apply it to mainnet, we should use

CREATE INDEX CONCURRENTLY transactions_sorting_idx ON transactions(block_timestamp, index_in_chunk);

(We never put CONCURRENTLY to migration files, I decided that I should be consistent here)

Applying it to 35.233.39.106 (it's copy of mainnet with data till 10th of May 2021) took 75 seconds.
Select from @frol works in a moment.
Important: columns block_timestamp, index_in_chunkshould always go in this order, and we should specify desc for both or for no columns. That anyway sounds logical.

select pg_size_pretty(pg_table_size('transactions_sorting_idx'));

For 14M lines, it took 550 MB of storage. Mainnet has 17M lines, so hopefully it should not be so far from these numbers.

Can I apply it to mainnet?

@telezhnaya telezhnaya requested a review from frol August 2, 2021 15:48
@frol frol merged commit 465646c into master Aug 3, 2021
@frol frol deleted the olya/add_index branch August 3, 2021 21:10
@frol frol changed the title feat: speed up sorting in transactions feat: introduced an index on transactions to speed up sorting by block_timestamp and index_in_chunk Aug 3, 2021
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.

Optimize transactions list query performance
2 participants