Skip to content

Commit 61efdca

Browse files
committed
backfill: add a separate control for number of vectors merged per batch
Add the 'bulkio.index_backfill.vector_merge_batch_size', which controls the number of rows to merge into vector indexes per transaction while the index is being created. This is analogous to the 'bulkio.index_backfill.merge_batch_size' setting, but it only applies when the target index is a vector index. By default, 3 vectors will be merged per transaction to reduce contention with fixup tasks. Fixes: #155283 Release note (sql change): Added the bulkio.index_backfill.vector_merge_batch_size cluster setting to control how many vectors to merge into a vector index per transaction during create operations. By default, this defaults to 3.
1 parent d36e5f2 commit 61efdca

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

pkg/sql/backfill/mvcc_index_merger.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,17 @@ var indexBackfillMergeBatchSize = settings.RegisterIntSetting(
4747
settings.NonNegativeInt, /* validateFn */
4848
)
4949

50+
// indexBackfillVectorMergeBatchSize is the maximum number of vectors we attempt to merge
51+
// in a single transaction during the merging process. This is a much smaller number because
52+
// fixups create a lot of conflicts with big batches.
53+
var indexBackfillVectorMergeBatchSize = settings.RegisterIntSetting(
54+
settings.ApplicationLevel,
55+
"bulkio.index_backfill.vector_merge_batch_size",
56+
"the number of vectors we merge between temporary and adding indexes in a single batch",
57+
3,
58+
settings.NonNegativeInt, /* validateFn */
59+
)
60+
5061
// indexBackfillMergeBatchBytes is the maximum number of bytes we attempt to
5162
// merge from the temporary index in a single transaction during the merging
5263
// process.
@@ -315,7 +326,12 @@ func (ibm *IndexBackfillMerger) scan(
315326
}
316327
}
317328
}
318-
chunkSize := indexBackfillMergeBatchSize.Get(&ibm.flowCtx.Cfg.Settings.SV)
329+
var chunkSize int64
330+
if _, ok := ibm.VectorIndexes[ibm.spec.AddedIndexes[spanIdx]]; ok {
331+
chunkSize = indexBackfillVectorMergeBatchSize.Get(&ibm.flowCtx.Cfg.Settings.SV)
332+
} else {
333+
chunkSize = indexBackfillMergeBatchSize.Get(&ibm.flowCtx.Cfg.Settings.SV)
334+
}
319335
chunkBytes := indexBackfillMergeBatchBytes.Get(&ibm.flowCtx.Cfg.Settings.SV)
320336

321337
var br *kvpb.BatchResponse

0 commit comments

Comments
 (0)