Skip to content

Commit

Permalink
sql: add cluster setting for merge batch size in index merger
Browse files Browse the repository at this point in the history
Release note: None
  • Loading branch information
stevendanna committed Feb 10, 2022
1 parent 0ab10e6 commit 14b144a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
11 changes: 11 additions & 0 deletions pkg/sql/backfill.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,17 @@ var indexBackfillBatchSize = settings.RegisterIntSetting(
settings.NonNegativeInt, /* validateFn */
)

// indexBackfillMergeBatchSize is the maximum number of rows we
// attempt to merge in a single transaction during the merging
// process.
var indexBackfillMergeBatchSize = settings.RegisterIntSetting(
settings.TenantWritable,
"bulkio.index_backfill.merge_batch_size",
"the number of rows we merge between temporary and adding indexes in a single batch",
1000,
settings.NonNegativeInt, /* validateFn */
)

// columnBackfillBatchSize is the maximum number of rows we update at once when
// adding or removing columns.
var columnBackfillBatchSize = settings.RegisterIntSetting(
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/mvcc_backfiller.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (im *IndexBackfillerMergePlanner) plan(
evalCtx = createSchemaChangeEvalCtx(ctx, im.execCfg, txn.ReadTimestamp(), descriptors)
planCtx = im.execCfg.DistSQLPlanner.NewPlanningCtx(ctx, &evalCtx, nil /* planner */, txn,
true /* distribute */)
chunkSize := indexBackfillBatchSize.Get(&im.execCfg.Settings.SV)
chunkSize := indexBackfillMergeBatchSize.Get(&im.execCfg.Settings.SV)

spec, err := initIndexBackfillMergerSpec(*tableDesc.TableDesc(), chunkSize, addedIndexes, temporaryIndexes)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/mvcc_backfiller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func TestRaceWithIndexBackfillMerge(t *testing.T) {

// TODO(rui): use testing hook instead of cluster setting once this value for
// the backfill merge is hooked up to testing hooks.
if _, err := sqlDB.Exec(fmt.Sprintf(`SET CLUSTER SETTING bulkio.index_backfill.batch_size = %d`, chunkSize)); err != nil {
if _, err := sqlDB.Exec(fmt.Sprintf(`SET CLUSTER SETTING bulkio.index_backfill.merge_batch_size = %d`, chunkSize)); err != nil {
t.Fatal(err)
}

Expand Down

0 comments on commit 14b144a

Please sign in to comment.