Skip to content

Commit

Permalink
chore: add setting auto_compaction_segments_limit (#16298)
Browse files Browse the repository at this point in the history
add setting auto_compaction_segments_limit
  • Loading branch information
zhyass authored Aug 21, 2024
1 parent 8057a1e commit 501f706
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/query/service/src/interpreters/hook/compact_hook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ async fn do_hook_compact(
// for mutations other than Insertions, we use an empirical value of 3 segments as the
// limit for compaction. to be refined later.
{
let auto_compaction_segments_limit = ctx.get_settings().get_auto_compaction_segments_limit()?;
CompactionLimits {
segment_limit: Some(3),
segment_limit: Some(auto_compaction_segments_limit as usize),
block_limit: None,
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/query/settings/src/settings_default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,12 @@ impl DefaultSettings {
mode: SettingMode::Both,
range: Some(SettingRange::Numeric(0..=u64::MAX)),
}),
("auto_compaction_segments_limit", DefaultSettingValue {
value: UserSettingValue::UInt64(3),
desc: "The maximum number of segments that can be compacted automatically triggered after write(replace-into/merge-into).",
mode: SettingMode::Both,
range: Some(SettingRange::Numeric(2..=u64::MAX)),
}),
("use_parquet2", DefaultSettingValue {
value: UserSettingValue::UInt64(0),
desc: "This setting is deprecated",
Expand Down
4 changes: 4 additions & 0 deletions src/query/settings/src/settings_getter_setter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,10 @@ impl Settings {
self.try_set_u64("auto_compaction_imperfect_blocks_threshold", val)
}

pub fn get_auto_compaction_segments_limit(&self) -> Result<u64> {
self.try_get_u64("auto_compaction_segments_limit")
}

pub fn get_use_parquet2(&self) -> Result<bool> {
Ok(self.try_get_u64("use_parquet2")? != 0)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,22 @@ statement ok
insert into t values(1);


# fourth block(after compaction)
statement ok
set auto_compaction_segments_limit = 2;

statement ok
insert into t values(1);

statement ok
replace into t on(c) values(2);

query III
select segment_count , block_count , row_count from fuse_snapshot('i15760', 't') limit 20;
----
2 4 11
3 5 11
2 4 10
1 3 9
4 5 9
3 4 8
Expand All @@ -57,4 +70,4 @@ select segment_count , block_count , row_count from fuse_snapshot('i15760', 't')
1 1 3
3 3 3
2 2 2
1 1 1
1 1 1

0 comments on commit 501f706

Please sign in to comment.