diff --git a/pkg/planner/core/operator/logicalop/logical_aggregation.go b/pkg/planner/core/operator/logicalop/logical_aggregation.go index 88968dba476ef..391784a5205c3 100644 --- a/pkg/planner/core/operator/logicalop/logical_aggregation.go +++ b/pkg/planner/core/operator/logicalop/logical_aggregation.go @@ -135,8 +135,7 @@ func (la *LogicalAggregation) PruneColumns(parentUsedCols []*expression.Column, } logicaltrace.AppendColumnPruneTraceStep(la, prunedColumns, opt) logicaltrace.AppendFunctionPruneTraceStep(la, prunedFunctions, opt) - //nolint: prealloc - var selfUsedCols []*expression.Column + selfUsedCols := make([]*expression.Column, 0, 5) for _, aggrFunc := range la.AggFuncs { selfUsedCols = expression.ExtractColumnsFromExpressions(selfUsedCols, aggrFunc.Args, nil) @@ -597,13 +596,12 @@ func (la *LogicalAggregation) pushDownCNFPredicatesForAggregation(cond expressio // (a > 1 and avg(b) > 1) or (a < 3), and `avg(b) > 1` can't be pushed-down. // Then condsToPush: (a < 3) and (a > 1), ret: (a > 1 and avg(b) > 1) or (a < 3) func (la *LogicalAggregation) pushDownDNFPredicatesForAggregation(cond expression.Expression, groupByColumns *expression.Schema, exprsOriginal []expression.Expression) ([]expression.Expression, []expression.Expression) { - //nolint: prealloc - var condsToPush []expression.Expression - var ret []expression.Expression subDNFItem := expression.SplitDNFItems(cond) if len(subDNFItem) == 1 { return la.pushDownPredicatesForAggregation(subDNFItem[0], groupByColumns, exprsOriginal) } + condsToPush := make([]expression.Expression, 0, len(subDNFItem)) + var ret []expression.Expression exprCtx := la.SCtx().GetExprCtx() for _, item := range subDNFItem { condsToPushForItem, retForItem := la.pushDownCNFPredicatesForAggregation(item, groupByColumns, exprsOriginal) diff --git a/pkg/planner/core/rule_join_reorder.go b/pkg/planner/core/rule_join_reorder.go index 1bd970609dff3..81dc479b560f0 100644 --- a/pkg/planner/core/rule_join_reorder.go +++ b/pkg/planner/core/rule_join_reorder.go @@ -796,8 +796,7 @@ func findRoots(t *tracing.PlanTrace) []*tracing.PlanTrace { if t.TP == plancodec.TypeJoin || t.TP == plancodec.TypeDataSource { return []*tracing.PlanTrace{t} } - //nolint: prealloc - var r []*tracing.PlanTrace + r := make([]*tracing.PlanTrace, 0, 5) for _, child := range t.Children { r = append(r, findRoots(child)...) } diff --git a/pkg/planner/core/rule_join_reorder_dp.go b/pkg/planner/core/rule_join_reorder_dp.go index 804a5714f88fd..860e7d7ee6d32 100644 --- a/pkg/planner/core/rule_join_reorder_dp.go +++ b/pkg/planner/core/rule_join_reorder_dp.go @@ -216,11 +216,7 @@ func (s *joinReorderDPSolver) dpGraph(visitID2NodeID, nodeID2VisitID []int, _ [] func (*joinReorderDPSolver) nodesAreConnected(leftMask, rightMask uint, oldPos2NewPos []int, totalEqEdges []joinGroupEqEdge, totalNonEqEdges []joinGroupNonEqEdge) ([]joinGroupEqEdge, []expression.Expression) { - //nolint: prealloc var usedEqEdges []joinGroupEqEdge - //nolint: prealloc - var otherConds []expression.Expression - for _, edge := range totalEqEdges { lIdx := uint(oldPos2NewPos[edge.nodeIDs[0]]) rIdx := uint(oldPos2NewPos[edge.nodeIDs[1]]) @@ -228,6 +224,7 @@ func (*joinReorderDPSolver) nodesAreConnected(leftMask, rightMask uint, oldPos2N usedEqEdges = append(usedEqEdges, edge) } } + otherConds := make([]expression.Expression, 0, len(totalNonEqEdges)) for _, edge := range totalNonEqEdges { // If the result is false, means that the current group hasn't covered the columns involved in the expression. if edge.nodeIDMask&(leftMask|rightMask) != edge.nodeIDMask {