[CP] fix bug of NO_GATHER_OPTIMIZER_STATISTICS no affect

This commit is contained in:
obdev
2024-02-09 01:46:18 +00:00
committed by ob-robot
parent 44879cf7d6
commit 4240f522b0
3 changed files with 27 additions and 3 deletions

View File

@ -78,6 +78,7 @@ int ObTableDirectInsertCtx::init(ObExecContext *exec_ctx,
param.max_error_row_count_ = 0; param.max_error_row_count_ = 0;
param.dup_action_ = sql::ObLoadDupActionType::LOAD_STOP_ON_DUP; param.dup_action_ = sql::ObLoadDupActionType::LOAD_STOP_ON_DUP;
param.sql_mode_ = sql_mode; param.sql_mode_ = sql_mode;
param.online_opt_stat_gather_ = is_online_gather_statistics_;
if (OB_FAIL(table_load_instance_->init(param, store_column_idxs, load_exec_ctx_))) { if (OB_FAIL(table_load_instance_->init(param, store_column_idxs, load_exec_ctx_))) {
LOG_WARN("failed to init direct loader", KR(ret)); LOG_WARN("failed to init direct loader", KR(ret));
} else { } else {

View File

@ -33,7 +33,8 @@ public:
: load_exec_ctx_(nullptr), : load_exec_ctx_(nullptr),
table_load_instance_(nullptr), table_load_instance_(nullptr),
is_inited_(false), is_inited_(false),
is_direct_(false) {} is_direct_(false),
is_online_gather_statistics_(false) {}
~ObTableDirectInsertCtx(); ~ObTableDirectInsertCtx();
TO_STRING_KV(K_(is_inited)); TO_STRING_KV(K_(is_inited));
public: public:
@ -44,6 +45,13 @@ public:
bool get_is_direct() const { return is_direct_; } bool get_is_direct() const { return is_direct_; }
void set_is_direct(bool is_direct) { is_direct_ = is_direct; } void set_is_direct(bool is_direct) { is_direct_ = is_direct; }
bool get_is_online_gather_statistics() const {
return is_online_gather_statistics_;
}
void set_is_online_gather_statistics(const bool is_online_gather_statistics) {
is_online_gather_statistics_ = is_online_gather_statistics;
}
private: private:
int init_store_column_idxs(const uint64_t tenant_id, const uint64_t table_id, int init_store_column_idxs(const uint64_t tenant_id, const uint64_t table_id,
@ -53,6 +61,7 @@ private:
observer::ObTableLoadInstance *table_load_instance_; observer::ObTableLoadInstance *table_load_instance_;
bool is_inited_; bool is_inited_;
bool is_direct_; //indict whether the plan is direct load plan including insert into append and load data direct bool is_direct_; //indict whether the plan is direct load plan including insert into append and load data direct
bool is_online_gather_statistics_;
}; };
} // namespace observer } // namespace observer
} // namespace oceanbase } // namespace oceanbase

View File

@ -95,8 +95,22 @@ int ObInsertLogPlan::generate_normal_raw_plan()
LOG_WARN("failed to compute dml parallel", K(ret)); LOG_WARN("failed to compute dml parallel", K(ret));
} else if (use_pdml() && OB_FAIL(set_is_direct_insert())) { } else if (use_pdml() && OB_FAIL(set_is_direct_insert())) {
LOG_WARN("failed to set is direct insert", K(ret)); LOG_WARN("failed to set is direct insert", K(ret));
} else if (!is_direct_insert() && OB_FAIL(check_need_online_stats_gather(need_osg))) { }
LOG_WARN("fail to check wether we need optimizer stats gathering operator", K(ret)); if (OB_SUCC(ret)) {
bool tmp_need_osg = false;
if (OB_FAIL(check_need_online_stats_gather(tmp_need_osg))) {
LOG_WARN("fail to check wether we need optimizer stats gathering operator", K(ret));
} else {
if (is_direct_insert()) {
get_optimizer_context().get_exec_ctx()->get_table_direct_insert_ctx()
.set_is_online_gather_statistics(tmp_need_osg);
} else {
need_osg = tmp_need_osg;
}
}
}
if (OB_FAIL(ret)) {
//pass
} else if (need_osg && OB_FAIL(generate_osg_share_info(osg_info))) { } else if (need_osg && OB_FAIL(generate_osg_share_info(osg_info))) {
LOG_WARN("failed to generate osg share info"); LOG_WARN("failed to generate osg share info");
} else if (need_osg && OB_ISNULL(osg_info)) { } else if (need_osg && OB_ISNULL(osg_info)) {