Skip to content

Commit 1d55d57

Browse files
authored
feat(query): add distributed pruning settings (#16864)
chore(query): add distributed pruning settings
1 parent 55cef11 commit 1d55d57

File tree

4 files changed

+55
-4
lines changed

4 files changed

+55
-4
lines changed

src/query/settings/src/settings_default.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ impl DefaultSettings {
275275
mode: SettingMode::Both,
276276
range: Some(SettingRange::Numeric(0..=1)),
277277
}),
278-
("enable_dio", DefaultSettingValue{
278+
("enable_dio", DefaultSettingValue {
279279
value: UserSettingValue::UInt64(1),
280280
desc: "Enables Direct IO.",
281281
mode: SettingMode::Both,
@@ -880,7 +880,6 @@ impl DefaultSettings {
880880
mode: SettingMode::Both,
881881
range: Some(SettingRange::Numeric(0..=u64::MAX)),
882882
}),
883-
884883
("enable_auto_fix_missing_bloom_index", DefaultSettingValue {
885884
value: UserSettingValue::UInt64(0),
886885
desc: "Enables auto fix missing bloom index",
@@ -939,7 +938,13 @@ impl DefaultSettings {
939938
value: UserSettingValue::UInt64(128),
940939
desc: "Sets the maximum length for truncating SQL queries in short_sql function.",
941940
mode: SettingMode::Both,
942-
range: Some(SettingRange::Numeric(1..=1024*1024)),
941+
range: Some(SettingRange::Numeric(1..=1024 * 1024)),
942+
}),
943+
("enable_distributed_pruning", DefaultSettingValue {
944+
value: UserSettingValue::UInt64(1),
945+
desc: "Enable distributed index pruning, as it is very necessary and should remain enabled in the vast majority of cases.",
946+
mode: SettingMode::Both,
947+
range: Some(SettingRange::Numeric(0..=1)),
943948
}),
944949
]);
945950

src/query/settings/src/settings_getter_setter.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,4 +809,8 @@ impl Settings {
809809
pub fn set_short_sql_max_length(&self, val: u64) -> Result<()> {
810810
self.try_set_u64("short_sql_max_length", val)
811811
}
812+
813+
pub fn get_enable_distributed_pruning(&self) -> Result<bool> {
814+
Ok(self.try_get_u64("enable_distributed_pruning")? == 1)
815+
}
812816
}

src/query/storages/fuse/src/operations/read_partitions.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ impl FuseTable {
6161
push_downs: Option<PushDownInfo>,
6262
dry_run: bool,
6363
) -> Result<(PartStatistics, Partitions)> {
64+
let distributed_pruning = ctx.get_settings().get_enable_distributed_pruning()?;
6465
debug!("fuse table do read partitions, push downs:{:?}", push_downs);
6566
if let Some(changes_desc) = &self.changes_desc {
6667
// For "ANALYZE TABLE" statement, we need set the default change type to "Insert".
@@ -86,7 +87,7 @@ impl FuseTable {
8687
nodes_num = cluster.nodes.len();
8788
}
8889

89-
if !dry_run && snapshot.segments.len() > nodes_num {
90+
if !dry_run && snapshot.segments.len() > nodes_num && distributed_pruning {
9091
let mut segments = Vec::with_capacity(snapshot.segments.len());
9192
for (idx, segment_location) in snapshot.segments.iter().enumerate() {
9293
segments.push(FuseLazyPartInfo::create(idx, segment_location.clone()))
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
2+
statement ok
3+
create or replace database distributed_pruning;
4+
5+
statement ok
6+
use distributed_pruning;
7+
8+
statement ok
9+
CREATE or replace TABLE test_table(TEXT String);
10+
11+
12+
statement ok
13+
INSERT INTO test_table VALUES('test_text1');
14+
15+
statement ok
16+
INSERT INTO test_table VALUES('test_text2');
17+
18+
statement ok
19+
INSERT INTO test_table VALUES('test_text3');
20+
21+
statement ok
22+
INSERT INTO test_table VALUES('test_text4');
23+
24+
statement ok
25+
SET enable_distributed_pruning = 1;
26+
27+
query TTTTT
28+
SELECT COUNT() FROM test_table;
29+
----
30+
4
31+
32+
statement ok
33+
SET enable_distributed_pruning = 0;
34+
35+
query TTTTT
36+
SELECT COUNT() FROM test_table;
37+
----
38+
4
39+
40+
statement ok
41+
SET enable_distributed_pruning = 1;

0 commit comments

Comments
 (0)