Skip to content

Commit

Permalink
refactor(meta): use insert_many to reduce latency (#20120)
Browse files Browse the repository at this point in the history
  • Loading branch information
zwang28 authored Jan 13, 2025
1 parent 01e40c4 commit f8c7cad
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/meta/src/hummock/manager/time_travel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ impl HummockManager {
Ok(count)
}

let mut batch = vec![];
for (table_id, cg_id, committed_epoch) in tables_to_commit {
if !select_groups.contains(cg_id) {
continue;
Expand All @@ -454,8 +455,20 @@ impl HummockManager {
table_id: Set(table_id.table_id.into()),
version_id: Set(version_id.try_into().unwrap()),
};
batch.push(m);
// Use the same batch size as hummock_time_travel_sst_info_insert_batch_size.
if batch.len() >= self.env.opts.hummock_time_travel_sst_info_insert_batch_size {
// There should be no conflict rows.
hummock_epoch_to_version::Entity::insert_many(std::mem::take(&mut batch))
.do_nothing()
.exec(txn)
.await?;
}
}
if !batch.is_empty() {
// There should be no conflict rows.
hummock_epoch_to_version::Entity::insert(m)
hummock_epoch_to_version::Entity::insert_many(batch)
.do_nothing()
.exec(txn)
.await?;
}
Expand Down

0 comments on commit f8c7cad

Please sign in to comment.