Skip to content

Commit 6c18fa8

Browse files
authored
Merge pull request #4 from dantengsky/feat-setting-dist-copy
feat: new setting "enable_distributed_copy_into"
2 parents 25f07e5 + 1d97d4e commit 6c18fa8

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

src/query/service/tests/it/storages/testdata/settings_table.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ DB.Table: 'system'.'settings', Table: settings-table_id:1, ver:0, Engine: System
88
| 'efficiently_memory_group_by' | '0' | '0' | 'SESSION' | 'Memory is used efficiently, but this may cause performance degradation.' | 'UInt64' |
99
| 'enable_bushy_join' | '0' | '0' | 'SESSION' | 'Enables generating a bushy join plan with the optimizer.' | 'UInt64' |
1010
| 'enable_cbo' | '1' | '1' | 'SESSION' | 'Enables cost-based optimization.' | 'UInt64' |
11+
| 'enable_distributed_copy_into' | '1' | '1' | 'SESSION' | 'Enable distributed execution of copy into.' | 'UInt64' |
1112
| 'enable_dphyp' | '1' | '1' | 'SESSION' | 'Enables dphyp join order algorithm.' | 'UInt64' |
1213
| 'enable_query_result_cache' | '0' | '0' | 'SESSION' | 'Enables caching query results to improve performance for identical queries.' | 'UInt64' |
1314
| 'enable_runtime_filter' | '0' | '0' | 'SESSION' | 'Enables runtime filter optimization for JOIN.' | 'UInt64' |

src/query/settings/src/settings_default.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,12 @@ impl DefaultSettings {
310310
possible_values: None,
311311
display_in_show_settings: false,
312312
}),
313+
("enable_distributed_copy_into", DefaultSettingValue {
314+
value: UserSettingValue::UInt64(1),
315+
desc: "Enable distributed execution of copy into.",
316+
possible_values: None,
317+
display_in_show_settings: true,
318+
}),
313319
]);
314320

315321
Ok(Arc::new(DefaultSettings {

src/query/settings/src/settings_getter_setter.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,4 +362,12 @@ impl Settings {
362362
pub fn set_deduplicate_label(&self, val: String) -> Result<()> {
363363
self.set_setting("deduplicate_label".to_string(), val)
364364
}
365+
366+
pub fn get_enable_distributed_copy(&self) -> Result<bool> {
367+
Ok(self.try_get_u64("enable_distributed_copy_into")? != 0)
368+
}
369+
370+
pub fn set_enable_distributed_copy(&self, val: bool) -> Result<()> {
371+
self.try_set_u64("enable_distributed_copy_into", u64::from(val))
372+
}
365373
}

src/query/sql/src/planner/optimizer/optimizer.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use common_ast::ast::ExplainKind;
1919
use common_catalog::table_context::TableContext;
2020
use common_exception::ErrorCode;
2121
use common_exception::Result;
22+
use tracing::info;
2223

2324
use super::cost::CostContext;
2425
use super::format::display_memo;
@@ -138,7 +139,12 @@ pub fn optimize(
138139
Some(_) => CopyPlan::IntoTable(into_table),
139140
None => {
140141
into_table.enable_distributed =
141-
opt_ctx.config.enable_distributed_optimization;
142+
opt_ctx.config.enable_distributed_optimization
143+
&& ctx.get_settings().get_enable_distributed_copy()?;
144+
info!(
145+
"after optimization enable_distributed_copy? : {}",
146+
into_table.enable_distributed
147+
);
142148
CopyPlan::IntoTable(into_table)
143149
}
144150
},

0 commit comments

Comments
 (0)