-
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
executor: Support read operation for local temporary table #26353
executor: Support read operation for local temporary table #26353
Conversation
…nto temp_table_scan_reader
) | ||
|
||
// UnionIter implements kv.Iterator | ||
type UnionIter 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.
UnionIter
is moved to the client-go repo and is now internal
https://github.com/tikv/client-go/blob/master/internal/unionstore/union_iter.go
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.
Rest LGTM
@@ -4085,7 +4085,7 @@ func (b *PlanBuilder) buildDataSource(ctx context.Context, tn *ast.TableName, as | |||
|
|||
var result LogicalPlan = ds | |||
dirty := tableHasDirtyContent(b.ctx, tableInfo) | |||
if dirty { | |||
if dirty || tableInfo.TempTableType == model.TempTableLocal { |
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.
You may need to update some comments. Such as LogicalUnionScan
: "LogicalUnionScan is only used in non read-only txn.".
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.
Done
@@ -327,7 +328,7 @@ func (ds *DataSource) DeriveStats(childStats []*property.StatsInfo, selfSchema * | |||
} | |||
} | |||
} | |||
if isPossibleIdxMerge && sessionAndStmtPermission && needConsiderIndexMerge && isReadOnlyTxn { | |||
if isPossibleIdxMerge && sessionAndStmtPermission && needConsiderIndexMerge && isReadOnlyTxn && ds.tableInfo.TempTableType != model.TempTableLocal { |
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.
Why skip index merge?
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.
UnionScan for index merge is just a TODO, so we must skip is because local temporary table always use UnionScan.
Lines 308 to 320 in cca097d
// TODO: implement UnionScan + IndexMerge | |
isReadOnlyTxn := true | |
txn, err := ds.ctx.Txn(false) | |
if err != nil { | |
return nil, err | |
} | |
if txn.Valid() && !txn.IsReadOnly() { | |
isReadOnlyTxn = false | |
} | |
// Consider the IndexMergePath. Now, we just generate `IndexMergePath` in DNF case. | |
isPossibleIdxMerge := len(ds.pushedDownConds) > 0 && len(ds.possibleAccessPaths) > 1 | |
sessionAndStmtPermission := (ds.ctx.GetSessionVars().GetEnableIndexMerge() || len(ds.indexMergeHints) > 0) && !ds.ctx.GetSessionVars().StmtCtx.NoIndexMergeHint | |
// If there is an index path, we current do not consider `IndexMergePath`. |
[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. |
/merge |
This pull request has been accepted and is ready to merge. Commit hash: e569e42
|
/run-check_dev_2 |
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 1954958
|
What problem does this PR solve?
Issue Number: close #25920
Problem Summary:
Support read operation for local temporary table. PointGet/BatchPointGet are already supported in previous pr #26053 and #2629. So this pr finished last read operation for table scan.
What is changed and how it works?
For local temporary table, we force to use UnionScanExec to scan table for all data are in memory. We also introduced
UnionIter
to merge two MemBuff iters from session and transaction into one.Because
UnionScanExec
does not support index merge, so it is forbidden on local temporary table.Check List
Tests
Side effects
Documentation
Release note