-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
*: add explicit partition pruning to index joins (#32007) #32093
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
/run-unit-test |
2 similar comments
/run-unit-test |
/run-unit-test |
Code Coverage Details: https://codecov.io/github/pingcap/tidb/commit/91102dce63a0b1e91f29e23bd3dcc0d5e14f6d50 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious: does only IndexJoin
have this problem?
Great question! Not sure, but I just tried with Hash join and Merge join for the same query, and it does give the correct result.
Notice that the @djshow832 Which other types of joins needs to be tested? |
executor/builder.go
Outdated
if _, ok := explicitPartitionSelection[pid]; !ok { | ||
continue | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the partitions are already pruned by partitionProcessor.convertToIntSlice()
indirectly through partitionPruning()
in this code block.
Thus, I think the code branches where partitionPruning()
is not called may have the problem.
Not only joins but also other operators, which are hard to be tested fully. So I think the better way is to go through the code to check why |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid this is not the only place that missing the partition selection.
buildIndexReaderForIndexJoin / buildIndexLookupReaderForIndexJoin may have similiar issues...
The code is too complex, that's the real root cause for this kind of bug.
|
/merge |
This pull request has been accepted and is ready to merge. Commit hash: b7f8943
|
/run-unit-test |
/run-unit-test |
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
cherry pick to release-5.0 in PR #32929 |
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
cherry pick to release-5.1 in PR #32930 |
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
cherry pick to release-5.2 in PR #32931 |
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
cherry pick to release-5.3 in PR #32932 |
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
cherry pick to release-5.4 in PR #32933 |
What problem does this PR solve?
Issue Number: close #32007
Problem Summary:
Explicit partition selection
SELECT ... FROM pt PARTITION(p) ...
was not considered when buildTableReaderForIndexJoin().What is changed and how it works?
Use the PartitionNames (if set) and do skip looking up contents in non-mentioned partitions.
Check List
Tests
Side effects
Documentation
Release note