-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
planner, executor: index join enhancement #8471
Conversation
6fd3dbf
to
5bdb46f
Compare
7e053bf
to
029c6fd
Compare
/run-common-test |
a2685c7
to
3f4c9b9
Compare
} | ||
if len(nextColCmpFilterManager.OpType) == 0 { |
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.
We can let the manager hold the constant range too.
But this will lead to this situation: If there's no filter need to be computed at runtime. We can actually set the range information in planner. But if we use the manager hold the constant range, the constant range will be set during execution phase.
But this can save some codes.
Which one do you prefer?
access, eqConds, remained, keyOff2IdxOff := p.buildFakeEqCondsForIndexJoin(innerJoinKeys, idxCols, colLengths, innerPlan.pushedDownConds) | ||
// ColWithCompareOps is used in index join to handle the column with compare functions(>=, >, <, <=). | ||
// It stores the compare functions and build ranges in execution phase. | ||
type ColWithCompareOps struct { |
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.
Maybe we have a better name for this struct.
executor/index_lookup_join.go
Outdated
indexRanges []*ranger.Range | ||
keyOff2IdxOff []int | ||
indexRanges []*ranger.Range | ||
nextColCompareFilters *plannercore.ColWithCompareOps |
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.
Maybe we have a better name for this variable.
We need to modify the explain result of index join. |
When adding unit-test, found some incorrect result when index have prefix-string column. |
4e082a3
to
d9d51d8
Compare
/run-all-tests |
UPD: The failed case is caused by the incorrect behavior of |
The failed case is fixed by #8725 |
b13e136
to
7631437
Compare
6ff3cc1
to
19a06f3
Compare
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.
LGTM
@winoros Please fix the conflicts. |
// If the filter contains index column covered by join keys, it will be useless since we always use join key to build range for that index column.. | ||
for _, innerFilter := range innerPlan.pushedDownConds { | ||
affectedCols := expression.ExtractColumns(innerFilter) | ||
if expression.ColumnSliceIsIntersect(affectedCols, ijHelper.curPossibleUsedKeys) { |
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.
Seems that curPossibleUsedKeys
is always empty here because we build them in removeUselessEqAndInFunc
, which is after this.
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.
Removed this for
loop.
./run-all-tests |
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.
LGTM
What problem does this PR solve?
select * from t, tt where t.a=tt.a and tt.b >= t.b and tt.b < t.b+20
can usett.b >= t.b and tt.b < t.b+20
to build index join and access the inner table.What is changed and how it works?
We analyze the join key and filters as the following procedures:
column eq constant
orcolumn in (constant list)
.column from inner table compareOp expression only contain outer table's column and not a constant value
.3.1 union first two part, construct the template ranges that will be used in execution phase.
4.1 union this three part, construct the template ranges that will be used in execution phase.
When in execution phase, if there's re expressions found in 3. We will calculate it, build range for it and append it to the tail of the template range.
Check List
Tests
Code changes
Side effects
Related changes
This change is