-
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
plan,executor: support IndexJoin over UnionScan #7877
Conversation
/run-all-tests |
LGTM |
@@ -199,10 +204,8 @@ func (ds *DataSource) tryToGetDualTask() (task, error) { | |||
// findBestTask implements the PhysicalPlan interface. | |||
// It will enumerate all the available indices and choose a plan with least cost. | |||
func (ds *DataSource) findBestTask(prop *property.PhysicalProperty) (t task, err error) { | |||
// If ds is an inner plan in an IndexJoin, the IndexJoin will generate an inner plan by itself. | |||
// So here we do nothing. | |||
// TODO: Add a special prop to handle IndexJoin's inner plan. |
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.
Keep this TODO
?
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 have thought about adding this special prop in this patch, and then realized that current solution using nil for quick return is clear enough, so I removed this TODO.
physicalUnionScan.SetChildren(scan) | ||
scan = physicalUnionScan | ||
} | ||
return scan |
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.
465-473 and 516-524 maybe can extract a method, except this LGTM
@lysu comments addressed, PTAL. |
/run-all-tests |
LGTM |
What problem does this PR solve?
Fix pingcap/docs-cn#862
Before this PR,
IndexJoin
only applies when inner child isDataSource
. In the above issue, the join query is in a write transaction, so eachDataSource
would be decorated with anLogicalUnionScan
on top of it, thus makingIndexJoin
not applicable for the join implementation.What is changed and how it works?
First enhance executor to support
UnionScan
as inner child ofIndexJoin
, then we enableIndexJoin
forUnionScan
in planner.Below is the output after this PR:
Check List
Tests
Future works
IndexJoin
, we would callbuildAndSortAddedRows
to sort dirty table, we should consider caching the sorted dirty table for thisIndexJoin
operator;TableScan
orIndexScan
belowUnionScan
, we would build a new range according to each outer tuple now, shall we apply this onUnionScan
as well? if we do this, we cannot cache the sorted dirty table then, this should be a tradeoff;IndexJoin
cost, i.e, shall we updatePhysicalIndexJoin::getCost
to takeUnionScan
overhead into consideration?