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

Perf: Add metadata index by block hash to Clarity DB #5430

Closed
kantai opened this issue Nov 7, 2024 · 0 comments
Closed

Perf: Add metadata index by block hash to Clarity DB #5430

kantai opened this issue Nov 7, 2024 · 0 comments

Comments

@kantai
Copy link
Member

kantai commented Nov 7, 2024

The metadata_table in Clarity is normally queried by (key, blockhash) for which there is an index (due to the UNIQUE constraint), but during block commits, the metadata is moved from a placeholder blockhash to the final blockhash. This invokes UPDATE … WHERE blockhash = ? which requires a SCAN. With some naive perf analysis, this represented 388 samples out of 470 perf samples with process_next_nakamoto_block. Obviously, this could be a skewed sample, but adding an index here should be an easy performance boost:

CREATE INDEX IF NOT EXISTS md_blockhashes ON metadata_table(blockhash)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Status: ✅ Done
Development

No branches or pull requests

2 participants