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

Optimize the recent transactions query #119

Merged
merged 2 commits into from
Jan 4, 2023

Conversation

enobayram
Copy link
Contributor

@enobayram enobayram commented Jan 4, 2023

This PR optimizes the "recent transactions" query performed by chainweb-data at server start up. Before this PR, the query used the blocks.height column to order the query results, but we currently don't have an index on that column, so this query resulted in a full scan of the blocks table and unnecessarily delayed the server start up by a considerable amount of time.

This PR fixes that issue by instead using the transfers.height column which is supposed to have the same value and is also indexed.

@enobayram enobayram added performance minor A minor issue or PR labels Jan 4, 2023
@enobayram enobayram self-assigned this Jan 4, 2023
Now that we're reading the tx height from the transaction itself,
we don't have any reason left to JOIN on the blocks table
Copy link
Contributor

@emmanueldenloye emmanueldenloye left a comment

Choose a reason for hiding this comment

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

LGTM

@emmanueldenloye emmanueldenloye merged commit bddcf54 into master Jan 4, 2023
enobayram added a commit that referenced this pull request Mar 24, 2023
This PR removes the recentTxs tracking from the CW-D server state and always makes a DB query when recent transactions are needed.

With the current indexes that we have in place, the recent txs query is very fast to execute (see #119), so there's no need to complicate the server state for it anymore.

Note that, in addition to simplifying the codebase, this PR is also needed for the continuations search improvements mentioned [here](#66 (comment)) as well as for the planned work of decoupling the node listener from the HTTP API server.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor A minor issue or PR performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants