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 clean_node_table's query #17779

Merged

Conversation

AmineKhaldi
Copy link
Contributor

Before: real 37.100 user 21.069570 sys 16.029508 (87118718474 cycles)
After: real 23.564 user 18.518647 sys 5.043768 (53341553604 cycles)

Before:

QUERY PLAN
|--USING INDEX sqlite_autoindex_ancestors_1 FOR IN-OPERATOR
|--LIST SUBQUERY 5
|  |--MATERIALIZE pending_nodes
|  |  |--SETUP
|  |  |  `--SCAN root
|  |  `--RECURSIVE STEP
|  |     `--COMPOUND QUERY
|  |        |--LEFT-MOST SUBQUERY
|  |        |  |--SCAN pn
|  |        |  `--SEARCH n USING INDEX sqlite_autoindex_node_1 (hash=?)
|  |        `--UNION ALL
|  |           |--SCAN pn
|  |           `--SEARCH n USING INDEX sqlite_autoindex_node_1 (hash=?)
|  `--SCAN pending_nodes
`--SCAN node

After:

QUERY PLAN
|--LIST SUBQUERY 4
|  |--MATERIALIZE pending_nodes
|  |  |--SETUP
|  |  |  `--SCAN root
|  |  `--RECURSIVE STEP
|  |     `--COMPOUND QUERY
|  |        |--LEFT-MOST SUBQUERY
|  |        |  |--SCAN pn
|  |        |  `--SEARCH n USING INDEX sqlite_autoindex_node_1 (hash=?)
|  |        `--UNION ALL
|  |           |--SCAN pn
|  |           `--SEARCH n USING INDEX sqlite_autoindex_node_1 (hash=?)
|  |--SCAN n USING COVERING INDEX sqlite_autoindex_node_1
|  |--SEARCH a USING COVERING INDEX sqlite_autoindex_ancestors_1 (hash=?) LEFT-JOIN
|  |--CREATE AUTOMATIC INDEX ON pending_nodes(hash)
|  |--BLOOM FILTER ON pn (hash=?)
|  `--SEARCH pn USING AUTOMATIC COVERING INDEX (hash=?) LEFT-JOIN
`--SEARCH node USING COVERING INDEX sqlite_autoindex_node_1 (hash=?)

@AmineKhaldi AmineKhaldi added the Changed Required label for PR that categorizes merge commit message as "Changed" for changelog label Mar 26, 2024
@AmineKhaldi AmineKhaldi self-assigned this Mar 26, 2024
@AmineKhaldi AmineKhaldi marked this pull request as ready for review March 26, 2024 15:14
@AmineKhaldi AmineKhaldi requested a review from a team as a code owner March 26, 2024 15:14
Copy link
Contributor

@fchirica fchirica left a comment

Choose a reason for hiding this comment

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

They look completely equivalent to me (and the green CI is a good guarantee of this).

@emlowe emlowe added the ready_to_merge Submitter and reviewers think this is ready label Mar 27, 2024
@pmaslana pmaslana merged commit 2260808 into Chia-Network:main Mar 27, 2024
307 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changed Required label for PR that categorizes merge commit message as "Changed" for changelog DataLayer ready_to_merge Submitter and reviewers think this is ready
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants