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

Rewrite mysql PaginateBranchesFromHistoryTree query #3509

Merged
merged 2 commits into from
Oct 18, 2022

Conversation

dnr
Copy link
Member

@dnr dnr commented Oct 18, 2022

What changed?
Rewrite this query to use simple boolean expressions instead of tuple comparison.

Why?
For some reason mysql ends up using a full scan for this query even though the explain query plan looks reasonable.

How did you test it?
Tested with pre-release build on pipelines.

Potential risks

Is hotfix candidate?
yes

@dnr dnr requested a review from a team as a code owner October 18, 2022 20:16
ORDER BY shard_id, tree_id, branch_id
LIMIT ?`
FROM history_tree
WHERE shard_id = ? AND ((tree_id = ? AND branch_id > ?) OR tree_id > ?) OR shard_id > ?
Copy link
Member

Choose a reason for hiding this comment

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

maybe add some simple comment here that we tried the tuple comparison but it result in mysql doing stupid thing

@dnr dnr enabled auto-merge (squash) October 18, 2022 20:40
@dnr dnr merged commit 9cb646b into temporalio:master Oct 18, 2022
@dnr dnr deleted the mysql-history-query branch October 18, 2022 21: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.

None yet

2 participants