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

planner: avoid slicesgrow in the buildDataSource #58853

Merged
merged 3 commits into from
Jan 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions pkg/planner/core/logical_plan_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -4594,6 +4594,7 @@ func (b *PlanBuilder) buildDataSource(ctx context.Context, tn *ast.TableName, as
}
}
}
countCnt := len(columns) + 1 // +1 for an extra handle column
winoros marked this conversation as resolved.
Show resolved Hide resolved
ds := logicalop.DataSource{
DBName: dbName,
TableAsName: asName,
Expand All @@ -4604,16 +4605,16 @@ func (b *PlanBuilder) buildDataSource(ctx context.Context, tn *ast.TableName, as
IndexHints: b.TableHints().IndexHintList,
IndexMergeHints: indexMergeHints,
PossibleAccessPaths: possiblePaths,
Columns: make([]*model.ColumnInfo, 0, len(columns)),
Columns: make([]*model.ColumnInfo, 0, countCnt),
PartitionNames: tn.PartitionNames,
TblCols: make([]*expression.Column, 0, len(columns)),
TblCols: make([]*expression.Column, 0, countCnt),
PreferPartitions: make(map[int][]ast.CIStr),
IS: b.is,
IsForUpdateRead: b.isForUpdateRead,
}.Init(b.ctx, b.getSelectOffset())
var handleCols util.HandleCols
schema := expression.NewSchema(make([]*expression.Column, 0, len(columns))...)
names := make([]*types.FieldName, 0, len(columns))
schema := expression.NewSchema(make([]*expression.Column, 0, countCnt)...)
names := make([]*types.FieldName, 0, countCnt)
for i, col := range columns {
ds.Columns = append(ds.Columns, col.ToInfo())
names = append(names, &types.FieldName{
Expand Down