Skip to content

Commit f8c7cad

Browse files
authored
refactor(meta): use insert_many to reduce latency (#20120)
1 parent 01e40c4 commit f8c7cad

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/meta/src/hummock/manager/time_travel.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ impl HummockManager {
444444
Ok(count)
445445
}
446446

447+
let mut batch = vec![];
447448
for (table_id, cg_id, committed_epoch) in tables_to_commit {
448449
if !select_groups.contains(cg_id) {
449450
continue;
@@ -454,8 +455,20 @@ impl HummockManager {
454455
table_id: Set(table_id.table_id.into()),
455456
version_id: Set(version_id.try_into().unwrap()),
456457
};
458+
batch.push(m);
459+
// Use the same batch size as hummock_time_travel_sst_info_insert_batch_size.
460+
if batch.len() >= self.env.opts.hummock_time_travel_sst_info_insert_batch_size {
461+
// There should be no conflict rows.
462+
hummock_epoch_to_version::Entity::insert_many(std::mem::take(&mut batch))
463+
.do_nothing()
464+
.exec(txn)
465+
.await?;
466+
}
467+
}
468+
if !batch.is_empty() {
457469
// There should be no conflict rows.
458-
hummock_epoch_to_version::Entity::insert(m)
470+
hummock_epoch_to_version::Entity::insert_many(batch)
471+
.do_nothing()
459472
.exec(txn)
460473
.await?;
461474
}

0 commit comments

Comments
 (0)