From 9760ffd78088d6269df2f30279fffbd71e744747 Mon Sep 17 00:00:00 2001 From: coolfishchen Date: Thu, 11 Jul 2024 04:17:18 +0000 Subject: [PATCH] read ONLINE_ESTIMATE_PERCENT in direct load --- .../table_load/ob_table_load_client_task.cpp | 18 +++++++- .../engine/cmd/ob_load_data_direct_impl.cpp | 42 ++++++++++++------- 2 files changed, 44 insertions(+), 16 deletions(-) diff --git a/src/observer/table_load/ob_table_load_client_task.cpp b/src/observer/table_load/ob_table_load_client_task.cpp index f73ec9ca28..601c55cfd3 100644 --- a/src/observer/table_load/ob_table_load_client_task.cpp +++ b/src/observer/table_load/ob_table_load_client_task.cpp @@ -22,6 +22,7 @@ #include "observer/table_load/ob_table_load_task.h" #include "observer/table_load/ob_table_load_task_scheduler.h" #include "observer/table_load/ob_table_load_utils.h" +#include "share/stat/ob_dbms_stats_utils.h" namespace oceanbase { @@ -627,8 +628,21 @@ int ObTableLoadClientTask::init_instance() } else if (OB_FAIL(ObTableLoadSchema::get_tenant_optimizer_gather_stats_on_load( tenant_id, online_opt_stat_gather))) { LOG_WARN("fail to get tenant optimizer gather stats on load", KR(ret), K(tenant_id)); - } else { - ObTableLoadParam load_param; + } + + ObTableLoadParam load_param; + double online_sample_percent = 100.; + if (OB_SUCC(ret)) { + if (online_opt_stat_gather && + OB_FAIL(ObDbmsStatsUtils::get_sys_online_estimate_percent(exec_ctx_, + online_sample_percent))) { + LOG_WARN("failed to get sys online sample percent", K(ret)); + } else { + load_param.online_sample_percent_ = online_sample_percent; + } + } + + if (OB_SUCC(ret)) { load_param.tenant_id_ = tenant_id; load_param.table_id_ = table_id; load_param.parallel_ = param_.get_parallel(); diff --git a/src/sql/engine/cmd/ob_load_data_direct_impl.cpp b/src/sql/engine/cmd/ob_load_data_direct_impl.cpp index 6c7a21616c..f71b6bd087 100644 --- a/src/sql/engine/cmd/ob_load_data_direct_impl.cpp +++ b/src/sql/engine/cmd/ob_load_data_direct_impl.cpp @@ -2473,20 +2473,34 @@ int ObLoadDataDirectImpl::init_execute_context() load_param.method_ = execute_param_.method_; load_param.insert_mode_ = execute_param_.insert_mode_; load_param.load_mode_ = ObDirectLoadMode::LOAD_DATA; - if (OB_FAIL(ObTableLoadSchema::get_table_compressor_type( - execute_param_.tenant_id_, execute_param_.table_id_, table_compressor_type))) { - LOG_WARN("fail to get table compressor type", KR(ret)); - } else if (OB_FAIL(ObDDLUtil::get_temp_store_compress_type( - table_compressor_type, execute_param_.parallel_, load_param.compressor_type_))) { - LOG_WARN("fail to get tmp store compressor type", KR(ret)); - } else if (OB_FAIL(ObDbmsStatsUtils::get_sys_online_estimate_percent(*ctx_, - load_param.online_sample_percent_))) { - LOG_WARN("fail to get sys online estimate percent", KR(ret)); - } else if (OB_FAIL(direct_loader_.init(load_param, execute_param_.column_ids_, - &execute_ctx_.exec_ctx_))) { - LOG_WARN("fail to init direct loader", KR(ret)); - } else if (OB_FAIL(init_logger())) { - LOG_WARN("fail to init logger", KR(ret)); + + double online_sample_percent = 100.; + if (OB_SUCC(ret)) { + if (execute_param_.online_opt_stat_gather_ && + OB_FAIL(ObDbmsStatsUtils::get_sys_online_estimate_percent(*ctx_, + online_sample_percent))) { + LOG_WARN("failed to get sys online sample percent", K(ret)); + } else { + load_param.online_sample_percent_ = online_sample_percent; + } + } + + if (OB_SUCC(ret)) { + if (OB_FAIL(ObTableLoadSchema::get_table_compressor_type( + execute_param_.tenant_id_, execute_param_.table_id_, table_compressor_type))) { + LOG_WARN("fail to get table compressor type", KR(ret)); + } else if (OB_FAIL(ObDDLUtil::get_temp_store_compress_type( + table_compressor_type, execute_param_.parallel_, load_param.compressor_type_))) { + LOG_WARN("fail to get tmp store compressor type", KR(ret)); + } else if (OB_FAIL(ObDbmsStatsUtils::get_sys_online_estimate_percent(*ctx_, + load_param.online_sample_percent_))) { + LOG_WARN("fail to get sys online estimate percent", KR(ret)); + } else if (OB_FAIL(direct_loader_.init(load_param, execute_param_.column_ids_, + &execute_ctx_.exec_ctx_))) { + LOG_WARN("fail to init direct loader", KR(ret)); + } else if (OB_FAIL(init_logger())) { + LOG_WARN("fail to init logger", KR(ret)); + } } if (OB_SUCC(ret)) { execute_ctx_.direct_loader_ = &direct_loader_;