Skip to content

Commit

Permalink
Merge pull request cockroachdb#13374 from knz/backfill-limit
Browse files Browse the repository at this point in the history
sql: make the backfill code use a limitNode for chunking.
  • Loading branch information
knz authored Feb 2, 2017
2 parents 83ad50e + e3d1827 commit c10e3e8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
4 changes: 3 additions & 1 deletion pkg/sql/backfill.go
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,9 @@ func (sc *SchemaChanger) backfillIndexesChunk(
return err
}

if err := planner.startPlanWithLimit(rows, chunkSize); err != nil {
rows = &limitNode{p: planner, plan: rows, countExpr: parser.NewDInt(parser.DInt(chunkSize))}

if err := planner.startPlan(rows); err != nil {
return err
}

Expand Down
8 changes: 1 addition & 7 deletions pkg/sql/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
package sql

import (
"math"

"github.com/cockroachdb/cockroach/pkg/sql/parser"
"github.com/cockroachdb/cockroach/pkg/util/log"
"github.com/cockroachdb/cockroach/pkg/util/tracing"
Expand Down Expand Up @@ -211,18 +209,14 @@ func (p *planner) makePlan(stmt parser.Statement, autoCommit bool) (planNode, er

// startPlan starts the plan and all its sub-query nodes.
func (p *planner) startPlan(plan planNode) error {
return p.startPlanWithLimit(plan, math.MaxInt64)
}

func (p *planner) startPlanWithLimit(plan planNode, numRowsNeeded int64) error {
if err := p.startSubqueryPlans(plan); err != nil {
return err
}
if err := plan.Start(); err != nil {
return err
}
// Trigger limit propagation through the plan and sub-queries.
applyLimit(plan, numRowsNeeded, false /* !soft */)
setUnlimited(plan)
return nil
}

Expand Down

0 comments on commit c10e3e8

Please sign in to comment.