[FEAT MERGE]优化器技术改造
Co-authored-by: JinmaoLi <ljm.csmaster@gmail.com> Co-authored-by: jingtaoye35 <1255153887@qq.com> Co-authored-by: chimyue <chimyue@gmail.com>
This commit is contained in:
parent
dab7652eee
commit
8aff09f2cd
@ -178,6 +178,7 @@ public:
|
||||
// session environment
|
||||
virtual int get_session_variable(const ObString &name, int64_t &val) = 0;
|
||||
virtual int set_session_variable(const ObString &name, int64_t val) = 0;
|
||||
virtual int set_session_variable(const ObString &name, const ObString &val) = 0;
|
||||
|
||||
virtual int execute(const uint64_t tenant_id, ObIExecutor &executor)
|
||||
{
|
||||
|
@ -98,7 +98,7 @@ public:
|
||||
// session environment
|
||||
virtual int get_session_variable(const ObString &name, int64_t &val) override;
|
||||
virtual int set_session_variable(const ObString &name, int64_t val) override;
|
||||
int set_session_variable(const ObString &name, const ObString &val);
|
||||
virtual int set_session_variable(const ObString &name, const ObString &val) override;
|
||||
|
||||
virtual int ping() override;
|
||||
int set_trace_id();
|
||||
|
@ -222,6 +222,9 @@ int ObCommonSqlProxy::write(const uint64_t tenant_id, const ObString sql,
|
||||
conn->set_force_remote_exec(true);
|
||||
conn->set_nls_formats(param->nls_formats_);
|
||||
}
|
||||
if (!param->secure_file_priv_.empty()) {
|
||||
conn->set_session_variable("secure_file_priv", param->secure_file_priv_);
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret) && nullptr != param && nullptr != param->sql_mode_) {
|
||||
// TODO(cangdi): fix get_session_variable not working
|
||||
|
@ -105,7 +105,8 @@ struct ObSessionParam final
|
||||
public:
|
||||
ObSessionParam()
|
||||
: sql_mode_(nullptr), tz_info_wrap_(nullptr), ddl_info_(), is_load_data_exec_(false),
|
||||
use_external_session_(false), consumer_group_id_(0), nls_formats_{}, enable_pl_cache_(true) {}
|
||||
use_external_session_(false), consumer_group_id_(0), nls_formats_{}, enable_pl_cache_(true),
|
||||
secure_file_priv_() {}
|
||||
~ObSessionParam() = default;
|
||||
public:
|
||||
int64_t *sql_mode_;
|
||||
@ -116,6 +117,7 @@ public:
|
||||
int64_t consumer_group_id_;
|
||||
common::ObString nls_formats_[common::ObNLSFormatEnum::NLS_MAX];
|
||||
bool enable_pl_cache_;
|
||||
common::ObString secure_file_priv_;
|
||||
};
|
||||
|
||||
// thread safe sql proxy
|
||||
|
@ -376,7 +376,8 @@ GLOBAL_ERRSIM_POINT_DEF(556, EN_GENERATE_RANDOM_PLAN, "Whether the optimizer gen
|
||||
GLOBAL_ERRSIM_POINT_DEF(557, EN_COALESCE_AGGR_IGNORE_COST, "");
|
||||
GLOBAL_ERRSIM_POINT_DEF(558, EN_CHECK_REWRITE_ITER_CONVERGE, "Reporting error when rewrite iter nonconvergent");
|
||||
GLOBAL_ERRSIM_POINT_DEF(559, EN_PRINT_CONSTRAINTS_INFO, "show constraints info when explain query plan");
|
||||
GLOBAL_ERRSIM_POINT_DEF(560, EN_PX_RANDOM_SHUFFLE_WITHOUT_STATISTIC_INFORMATION, "Use px random shuffle even statistical information do not exist.");
|
||||
GLOBAL_ERRSIM_POINT_DEF(560, EN_CBQT_IGNORE_COST, "Whether ignore the cost when do cost based transformation");
|
||||
GLOBAL_ERRSIM_POINT_DEF(561, EN_PX_RANDOM_SHUFFLE_WITHOUT_STATISTIC_INFORMATION, "Use px random shuffle even statistical information do not exist.");
|
||||
|
||||
// 600-700 For PX use
|
||||
GLOBAL_ERRSIM_POINT_DEF(600, EN_PX_SQC_EXECUTE_FAILED, "");
|
||||
|
@ -2081,6 +2081,18 @@ int ObInnerSQLConnection::set_session_variable(const ObString &name, int64_t val
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObInnerSQLConnection::set_session_variable(const ObString &name, const ObString &val)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (!inited_) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("not init", K(ret));
|
||||
} else if (OB_FAIL(get_session().update_sys_variable(name, val))) {
|
||||
LOG_WARN("failed to update sys variable", K(ret), K(name), K(val));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
lib::Worker::CompatMode ObInnerSQLConnection::get_compat_mode() const
|
||||
{
|
||||
lib::Worker::CompatMode mode;
|
||||
|
@ -178,6 +178,7 @@ public:
|
||||
// session environment
|
||||
virtual int get_session_variable(const ObString &name, int64_t &val) override;
|
||||
virtual int set_session_variable(const ObString &name, int64_t val) override;
|
||||
virtual int set_session_variable(const ObString &name, const ObString &val) override;
|
||||
inline void set_spi_connection(bool is_spi_conn) { is_spi_conn_ = is_spi_conn; }
|
||||
int set_primary_schema_version(const common::ObIArray<int64_t> &primary_schema_versions);
|
||||
|
||||
|
@ -693,7 +693,7 @@ int ObAllVirtualProxySchema::get_view_decoded_schema_(
|
||||
LOG_WARN("create query context failed", KR(ret));
|
||||
} else {
|
||||
// set # of question marks
|
||||
resolver_ctx.query_ctx_->question_marks_count_ = static_cast<int64_t> (parse_result.question_mark_ctx_.count_);
|
||||
resolver_ctx.query_ctx_->set_questionmark_count(static_cast<int64_t> (parse_result.question_mark_ctx_.count_));
|
||||
}
|
||||
if (OB_SUCC(ret)
|
||||
&& OB_NOT_NULL(parse_result.result_tree_)
|
||||
|
@ -1223,7 +1223,7 @@ int ObTableColumns::resolve_view_definition(
|
||||
LOG_WARN("create query context failed", K(ret));
|
||||
} else {
|
||||
// set # of question marks
|
||||
resolver_ctx.query_ctx_->question_marks_count_ = static_cast<int64_t> (parse_result.question_mark_ctx_.count_);
|
||||
resolver_ctx.query_ctx_->set_questionmark_count(static_cast<int64_t> (parse_result.question_mark_ctx_.count_));
|
||||
resolver_ctx.query_ctx_->sql_schema_guard_.set_schema_guard(schema_guard);
|
||||
uint64_t session_id = 0;
|
||||
if (session->get_session_type() != ObSQLSessionInfo::INNER_SESSION) {
|
||||
|
@ -599,6 +599,10 @@
|
||||
INTERFACE_DEF(INTERFACE_DBMS_SPM_LOAD_PLANS_FROM_CURSOR_CACHE, "LOAD_PLANS_FROM_CURSOR_CACHE", (ObDBMSSpm::load_plans_from_cursor_cache))
|
||||
INTERFACE_DEF(INTERFACE_DBMS_SPM_BATCH_LOAD_PLANS_FROM_CURSOR_CACHE, "BATCH_LOAD_PLANS_FROM_CURSOR_CACHE", (ObDBMSSpm::batch_load_plans_from_cursor_cache))
|
||||
INTERFACE_DEF(INTERFACE_DBMS_SPM_AUTO_PURGE_SQL_PLAN_BASELINE, "AUTO_PURGE_SQL_PLAN_BASELINE", (ObDBMSSpm::auto_purge_sql_plan_baseline))
|
||||
INTERFACE_DEF(INTERFACE_DBMS_SPM_UNPACK_STGTAB_BASELINE, "UNPACK_STGTAB_BASELINE", (ObDBMSSpm::unpack_table_baseline))
|
||||
INTERFACE_DEF(INTERFACE_DBMS_SPM_PACK_CSV_BASELINE, "PACK_CSV_BASELINE", (ObDBMSSpm::pack_csv_baseline))
|
||||
INTERFACE_DEF(INTERFACE_DBMS_SPM_UNPACK_CSV_BASELINE, "UNPACK_CSV_BASELINE", (ObDBMSSpm::unpack_csv_baseline))
|
||||
INTERFACE_DEF(INTERFACE_DBMS_SPM_HANDLE_SPM_STATS_JOB_PROC, "HANDLE_SPM_STATS_JOB_PROC", (ObDBMSSpm::handle_spm_stats_job_proc))
|
||||
// end of dbms_spm
|
||||
#endif
|
||||
|
||||
|
@ -2430,8 +2430,7 @@ int ObPLResolver::get_view_select_stmt(
|
||||
OX (resolver_ctx.expr_factory_ = &expr_factory);
|
||||
OX (resolver_ctx.stmt_factory_ = &stmt_factory);
|
||||
CK (OB_NOT_NULL(resolver_ctx.query_ctx_ = stmt_factory.get_query_ctx()));
|
||||
OX (resolver_ctx.query_ctx_->question_marks_count_
|
||||
= static_cast<int64_t>(parse_result.question_mark_ctx_.count_));
|
||||
OX (resolver_ctx.query_ctx_->set_questionmark_count(static_cast<int64_t>(parse_result.question_mark_ctx_.count_)));
|
||||
|
||||
CK (OB_NOT_NULL(select_stmt_node = parse_result.result_tree_->children_[0]));
|
||||
CK (T_SELECT == select_stmt_node->type_);
|
||||
@ -2521,8 +2520,7 @@ int ObPLResolver::fill_record_type(
|
||||
OX (resolver_ctx.sql_proxy_ = &(ctx.sql_proxy_)); \
|
||||
CK (OB_NOT_NULL(resolver_ctx.query_ctx_ = stmt_factory.get_query_ctx())); \
|
||||
OX (resolver_ctx.query_ctx_->sql_schema_guard_.set_schema_guard(&ctx.schema_guard_)); \
|
||||
OX (resolver_ctx.query_ctx_->question_marks_count_ \
|
||||
= static_cast<int64_t>(parse_result.question_mark_ctx_.count_)); \
|
||||
OX (resolver_ctx.query_ctx_->set_questionmark_count(static_cast<int64_t>(parse_result.question_mark_ctx_.count_))); \
|
||||
OZ (resolver_ctx.schema_checker_->init(resolver_ctx.query_ctx_->sql_schema_guard_, \
|
||||
ctx.session_info_.get_sessid())); \
|
||||
CK (OB_NOT_NULL(select_stmt_node = parse_result.result_tree_->children_[0]));\
|
||||
|
@ -178,10 +178,10 @@ int ObDbmsStats::gather_schema_stats(ObExecContext &ctx, ParamStore ¶ms, ObO
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
UNUSED(result);
|
||||
ObTableStatParam global_param;
|
||||
global_param.allocator_ = &ctx.get_allocator();
|
||||
ObSEArray<uint64_t, 4> table_ids;
|
||||
ObOptStatTaskInfo task_info;
|
||||
SMART_VAR(ObTableStatParam, global_param){
|
||||
global_param.allocator_ = &ctx.get_allocator();
|
||||
int64_t start_time = ObTimeUtility::current_time();
|
||||
if (OB_FAIL(check_statistic_table_writeable(ctx))) {
|
||||
LOG_WARN("failed to check tenant is restore", K(ret));
|
||||
@ -287,6 +287,7 @@ int ObDbmsStats::gather_schema_stats(ObExecContext &ctx, ParamStore ¶ms, ObO
|
||||
task_info.failed_count_ = ret == OB_SUCCESS ? 0 : table_ids.count() - i + 1;
|
||||
update_optimizer_gather_stat_info(&task_info, NULL);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -3636,6 +3637,7 @@ int ObDbmsStats::init_column_stat_params(ObIAllocator &allocator,
|
||||
col_param.bucket_num_ = -1;
|
||||
col_param.column_attribute_ = 0;
|
||||
col_param.column_usage_flag_ = 0;
|
||||
col_param.column_type_ = col->get_data_type();
|
||||
if (lib::is_oracle_mode() && col->get_meta_type().is_varbinary_or_binary()) {
|
||||
//oracle don't have this type. but agent table will have this type, such as "SYS"."ALL_VIRTUAL_COLUMN_REAL_AGENT"
|
||||
} else {
|
||||
@ -4442,6 +4444,14 @@ int ObDbmsStats::get_default_stat_options(ObExecContext &ctx,
|
||||
LOG_WARN("failed to push back", K(ret));
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret) && param.is_auto_gather_ && stat_options & StatOptionFlags::OPT_AUTO_SAMPLE_ROW_COUNT) {
|
||||
ObAutoSampleRowCountPrefs *tmp_pref = NULL;
|
||||
if (OB_FAIL(new_stat_prefs(*param.allocator_, ctx.get_my_session(), ObString(), tmp_pref))) {
|
||||
LOG_WARN("failed to new stat prefs", K(ret));
|
||||
} else if (OB_FAIL(stat_prefs.push_back(tmp_pref))) {
|
||||
LOG_WARN("failed to push back", K(ret));
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_FAIL(ObDbmsStatsPreferences::get_sys_default_stat_options(ctx, stat_prefs, param))) {
|
||||
LOG_WARN("failed to get sys default stat options", K(ret));
|
||||
@ -5982,6 +5992,7 @@ int ObDbmsStats::gather_table_stats_with_default_param(ObExecContext &ctx,
|
||||
stat_param.db_id_ = stat_table.database_id_;
|
||||
stat_param.is_async_gather_ = stat_table.is_async_gather_;
|
||||
stat_param.async_partition_ids_ = &stat_table.async_partition_ids_;
|
||||
stat_param.is_auto_gather_ = true;
|
||||
bool is_all_fast_gather = false;
|
||||
ObSEArray<int64_t, 4> no_gather_index_ids;
|
||||
ObOptStatGatherStat gather_stat(task_info);
|
||||
@ -5998,6 +6009,11 @@ int ObDbmsStats::gather_table_stats_with_default_param(ObExecContext &ctx,
|
||||
LOG_WARN("failed to parse owner", K(ret));
|
||||
} else if (OB_FAIL(use_default_gather_stat_options(ctx, stat_param))) {
|
||||
LOG_WARN("failed to use default gather stat optitions", K(ret));
|
||||
} else if (OB_FAIL(determine_auto_sample_table(ctx, stat_param))) {
|
||||
LOG_WARN("failed to determine auto sample table", K(ret));
|
||||
} else if (stat_param.is_auto_sample_size_ &&
|
||||
OB_FAIL(parse_refine_min_max_options(ctx, stat_param))) {
|
||||
LOG_WARN("failed to parse refine min max options", K(ret));
|
||||
} else if (!stat_table.is_async_gather_ &&
|
||||
OB_FAIL(adjust_auto_gather_stat_option(stat_table.partition_stat_infos_, stat_param))) {
|
||||
LOG_WARN("failed to use default gather stat optitions", K(ret));
|
||||
@ -6213,6 +6229,13 @@ int ObDbmsStats::get_new_stat_pref(ObExecContext &ctx,
|
||||
} else {
|
||||
stat_pref = tmp_pref;
|
||||
}
|
||||
} else if (is_global_prefs && 0 == opt_name.case_compare("AUTO_SAMPLE_ROW_COUNT")) {
|
||||
ObAutoSampleRowCountPrefs *tmp_pref = NULL;
|
||||
if (OB_FAIL(new_stat_prefs(allocator, ctx.get_my_session(), opt_value, tmp_pref))) {
|
||||
LOG_WARN("failed to new stat prefs", K(ret));
|
||||
} else {
|
||||
stat_pref = tmp_pref;
|
||||
}
|
||||
} else {
|
||||
ret = OB_ERR_DBMS_STATS_PL;
|
||||
LOG_WARN("Invalid input values for pname", K(ret), K(opt_name));
|
||||
@ -6222,7 +6245,8 @@ int ObDbmsStats::get_new_stat_pref(ObExecContext &ctx,
|
||||
"STALE_PERCENT | ESTIMATE_BLOCK | ASYNC_GATHER_STALE_RATIO |"\
|
||||
"ASYNC_GATHER_SAMPLE_SIZE | ASYNC_GATHER_FULL_TABLE_SIZE |"\
|
||||
"ASYNC_STALE_MAX_TABLE_SIZE | HIST_EST_PERCENT | HIST_BLOCK_SAMPLE |"\
|
||||
"APPROXIMATE_NDV(global prefs unique) | ONLINE_ESTIMATE_PERCENT prefs");
|
||||
"APPROXIMATE_NDV(global prefs unique) | ONLINE_ESTIMATE_PERCENT prefs |"\
|
||||
"AUTO_SAMPLE_ROW_COUNT(global prefs unique) prefs");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -7295,7 +7319,7 @@ int ObDbmsStats::adjust_async_gather_stat_option(ObExecContext &ctx,
|
||||
int ret = OB_SUCCESS;
|
||||
ObSEArray<int64_t, 4> approx_first_part_ids;
|
||||
//If the value of async_full_table_size_ is 0, it means that the table no need to async gather stats.
|
||||
if (param.async_full_table_size_ == 0) {
|
||||
if (param.auto_sample_row_cnt_ == 0) {
|
||||
param.subpart_stat_param_.reset_gather_stat();
|
||||
param.part_stat_param_.reset_gather_stat();
|
||||
param.global_stat_param_.reset_gather_stat();
|
||||
@ -7428,5 +7452,115 @@ int ObDbmsStats::adjust_text_column_basic_stats(ObExecContext &ctx,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObDbmsStats::parse_refine_min_max_options(ObExecContext &ctx,
|
||||
ObTableStatParam ¶m)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
uint64_t index_tids[OB_MAX_INDEX_PER_TABLE + 2];
|
||||
int64_t index_count = OB_MAX_INDEX_PER_TABLE + 1;
|
||||
share::schema::ObSchemaGetterGuard *schema_guard = ctx.get_virtual_table_ctx().schema_guard_;
|
||||
const share::schema::ObTableSchema *table_schema = NULL;
|
||||
ObSEArray<uint64_t, 4> refine_columns;
|
||||
ObSEArray<ObString, 4> refine_index_names;
|
||||
uint64_t first_column_id = OB_INVALID_ID;
|
||||
ObSEArray<uint64_t, 4> rowkey_ids;
|
||||
if (OB_ISNULL(schema_guard) ||
|
||||
OB_ISNULL(ctx.get_my_session()) ||
|
||||
OB_ISNULL(param.allocator_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected null", K(ret));
|
||||
} else if (OB_FAIL(schema_guard->get_table_schema(ctx.get_my_session()->get_effective_tenant_id(),
|
||||
param.table_id_,
|
||||
table_schema))) {
|
||||
LOG_WARN("failed to get index schema", K(ret));
|
||||
} else if (OB_ISNULL(table_schema)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected null", K(ret));
|
||||
} else if (OB_FAIL(get_table_index_infos(schema_guard,
|
||||
ctx.get_my_session()->get_effective_tenant_id(),
|
||||
param.table_id_,
|
||||
index_tids,
|
||||
index_count))) {
|
||||
LOG_WARN("failed to get table index infos", K(ret));
|
||||
} else {
|
||||
index_tids[index_count++] = param.table_id_;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < index_count; ++i) {
|
||||
const share::schema::ObTableSchema *index_schema = NULL;
|
||||
ObString index_name;
|
||||
rowkey_ids.reuse();
|
||||
if (OB_FAIL(schema_guard->get_table_schema(ctx.get_my_session()->get_effective_tenant_id(),
|
||||
index_tids[i],
|
||||
index_schema))) {
|
||||
LOG_WARN("failed to get index schema", K(ret));
|
||||
} else if (OB_ISNULL(index_schema)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected null", K(ret));
|
||||
} else if (OB_FAIL(index_schema->get_rowkey_column_ids(rowkey_ids))) {
|
||||
LOG_WARN("failed to get rowkey column ids", K(ret));
|
||||
} else if (rowkey_ids.empty()) {
|
||||
// do nothing
|
||||
} else if (OB_FALSE_IT(first_column_id = rowkey_ids.at(0))) {
|
||||
} else if (index_schema->is_global_index_table() &&
|
||||
table_schema->get_part_level() != ObPartitionLevel::PARTITION_LEVEL_ONE) {
|
||||
// do nothing
|
||||
} else if (ObOptimizerUtil::find_item(refine_columns, first_column_id)) {
|
||||
// do nothing
|
||||
} else if (index_tids[i] != param.table_id_ &&
|
||||
OB_FAIL(index_schema->get_index_name(index_name))) {
|
||||
LOG_WARN("failed to get index name", K(ret));
|
||||
} else if (OB_FAIL(refine_columns.push_back(first_column_id))) {
|
||||
LOG_WARN("failed to push back array", K(ret));
|
||||
} else if (OB_FAIL(refine_index_names.push_back(index_name))) {
|
||||
LOG_WARN("failed to push back array", K(ret));
|
||||
}
|
||||
}
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < param.column_params_.count(); ++i) {
|
||||
int64_t index = -1;
|
||||
if (!param.column_params_.at(i).need_basic_stat()) {
|
||||
// do nothing
|
||||
} else if (!ObOptimizerUtil::find_item(refine_columns,
|
||||
param.column_params_.at(i).column_id_,
|
||||
&index)) {
|
||||
// do nothing
|
||||
} else if (OB_FAIL(ob_write_string(*param.allocator_,
|
||||
refine_index_names.at(index),
|
||||
param.column_params_.at(i).index_name_))) {
|
||||
LOG_WARN("failed to write string", K(ret));
|
||||
} else {
|
||||
param.column_params_.at(i).set_need_refine_min_max();
|
||||
param.need_refine_min_max_ = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObDbmsStats::determine_auto_sample_table(ObExecContext &ctx,
|
||||
ObTableStatParam ¶m)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
share::schema::ObSchemaGetterGuard *schema_guard = ctx.get_virtual_table_ctx().schema_guard_;
|
||||
const share::schema::ObTableSchema *table_schema = NULL;
|
||||
if (param.auto_sample_row_cnt_ == 0) {
|
||||
param.is_auto_sample_size_ = false;
|
||||
} else if (!param.is_auto_sample_size_) {
|
||||
// do nothing
|
||||
} else if (OB_ISNULL(schema_guard) ||
|
||||
OB_ISNULL(ctx.get_my_session())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected null", K(ret));
|
||||
} else if (OB_FAIL(schema_guard->get_table_schema(ctx.get_my_session()->get_effective_tenant_id(),
|
||||
param.table_id_,
|
||||
table_schema))) {
|
||||
LOG_WARN("failed to get index schema", K(ret));
|
||||
} else if (OB_ISNULL(table_schema)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected null", K(ret));
|
||||
} else {
|
||||
param.is_auto_sample_size_ = !table_schema->is_vir_table();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -545,6 +545,13 @@ public:
|
||||
static void update_optimizer_gather_stat_info(const ObOptStatTaskInfo *task_info,
|
||||
const ObOptStatGatherStat *gather_stat);
|
||||
|
||||
static int convert_vaild_ident_name(common::ObIAllocator &allocator,
|
||||
const common::ObDataTypeCastParams &dtc_params,
|
||||
ObString &ident_name,
|
||||
bool need_extra_conv = false);
|
||||
static int parse_refine_min_max_options(ObExecContext &ctx,
|
||||
ObTableStatParam ¶m);
|
||||
|
||||
private:
|
||||
static int check_statistic_table_writeable(sql::ObExecContext &ctx);
|
||||
|
||||
@ -568,12 +575,6 @@ private:
|
||||
bool is_global_prefs,
|
||||
ObStatPrefs *&stat_pref);
|
||||
|
||||
static int convert_vaild_ident_name(common::ObIAllocator &allocator,
|
||||
const common::ObDataTypeCastParams &dtc_params,
|
||||
ObString &ident_name,
|
||||
bool need_extra_conv = false);
|
||||
|
||||
|
||||
static int get_common_table_stale_percent(sql::ObExecContext &ctx,
|
||||
const uint64_t tenant_id,
|
||||
const share::schema::ObTableSchema &table_schema,
|
||||
@ -667,6 +668,9 @@ private:
|
||||
const share::schema::ObTableSchema &schema,
|
||||
ObTableStatParam ¶m);
|
||||
|
||||
static int determine_auto_sample_table(ObExecContext &ctx,
|
||||
ObTableStatParam ¶m);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -548,6 +548,7 @@ ob_set_subtarget(ob_share stat
|
||||
stat/ob_dbms_stats_gather.cpp
|
||||
stat/ob_opt_system_stat.cpp
|
||||
stat/ob_opt_system_stat_cache.cpp
|
||||
stat/ob_min_max_estimator.cpp
|
||||
)
|
||||
|
||||
ob_set_subtarget(ob_share external_table
|
||||
|
@ -1151,6 +1151,14 @@ int64_t ObSqlPlanManagementModeChecker::get_spm_mode_by_string(const common::ObS
|
||||
spm_mode = 0;
|
||||
} else if (0 == string.case_compare("OnlineEvolve")) {
|
||||
spm_mode = 1;
|
||||
} else if (0 == string.case_compare("BaselineFirst")) {
|
||||
uint64_t cluster_version = GET_MIN_CLUSTER_VERSION();
|
||||
if (cluster_version >= CLUSTER_VERSION_4_3_5_0 ||
|
||||
(cluster_version >= MOCK_CLUSTER_VERSION_4_2_5_0 && cluster_version < CLUSTER_VERSION_4_3_0_0)) {
|
||||
spm_mode = 2;
|
||||
} else {
|
||||
spm_mode = -1;
|
||||
}
|
||||
}
|
||||
return spm_mode;
|
||||
}
|
||||
|
@ -8138,6 +8138,279 @@ int ObInnerTableSchema::all_virtual_kv_group_commit_status_schema(ObTableSchema
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObInnerTableSchema::all_virtual_spm_evo_result_schema(ObTableSchema &table_schema)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;
|
||||
|
||||
//generated fields:
|
||||
table_schema.set_tenant_id(OB_SYS_TENANT_ID);
|
||||
table_schema.set_tablegroup_id(OB_INVALID_ID);
|
||||
table_schema.set_database_id(OB_SYS_DATABASE_ID);
|
||||
table_schema.set_table_id(OB_ALL_VIRTUAL_SPM_EVO_RESULT_TID);
|
||||
table_schema.set_rowkey_split_pos(0);
|
||||
table_schema.set_is_use_bloomfilter(false);
|
||||
table_schema.set_progressive_merge_num(0);
|
||||
table_schema.set_rowkey_column_num(4);
|
||||
table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
|
||||
table_schema.set_table_type(VIRTUAL_TABLE);
|
||||
table_schema.set_index_type(INDEX_TYPE_IS_NOT);
|
||||
table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_FAIL(table_schema.set_table_name(OB_ALL_VIRTUAL_SPM_EVO_RESULT_TNAME))) {
|
||||
LOG_ERROR("fail to set table_name", K(ret));
|
||||
}
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
|
||||
LOG_ERROR("fail to set compress_func_name", K(ret));
|
||||
}
|
||||
}
|
||||
table_schema.set_part_level(PARTITION_LEVEL_ZERO);
|
||||
table_schema.set_charset_type(ObCharset::get_default_charset());
|
||||
table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("tenant_id", //column_name
|
||||
++column_id, //column_id
|
||||
1, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObIntType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
sizeof(int64_t), //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
false, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA_TS("record_time", //column_name
|
||||
++column_id, //column_id
|
||||
2, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObTimestampType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
sizeof(ObPreciseDateTime), //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
false, //is_nullable
|
||||
false, //is_autoincrement
|
||||
false); //is_on_update_for_timestamp
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("svr_ip", //column_name
|
||||
++column_id, //column_id
|
||||
3, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObVarcharType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
MAX_IP_ADDR_LENGTH, //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
false, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("svr_port", //column_name
|
||||
++column_id, //column_id
|
||||
4, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObIntType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
sizeof(int64_t), //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
false, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("database_id", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObIntType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
sizeof(int64_t), //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
false, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("sql_id", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObVarcharType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
OB_MAX_SQL_ID_LENGTH, //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
false, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("type", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObIntType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
sizeof(int64_t), //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
false, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA_TS("start_time", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObTimestampType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
sizeof(ObPreciseDateTime), //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
true, //is_nullable
|
||||
false, //is_autoincrement
|
||||
false); //is_on_update_for_timestamp
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA_TS("end_time", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObTimestampType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
sizeof(ObPreciseDateTime), //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
true, //is_nullable
|
||||
false, //is_autoincrement
|
||||
false); //is_on_update_for_timestamp
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("status", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObVarcharType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
7, //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
true, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("new_plan_better", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObTinyIntType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
1, //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
true, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("evo_plan_exec_count", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObIntType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
sizeof(int64_t), //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
true, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("evo_plan_cpu_time", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObIntType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
sizeof(int64_t), //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
true, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("baseline_exec_count", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObIntType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
sizeof(int64_t), //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
true, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("baseline_cpu_time", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObIntType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
sizeof(int64_t), //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
true, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
table_schema.set_index_using_type(USING_BTREE);
|
||||
table_schema.set_row_store_type(ENCODING_ROW_STORE);
|
||||
table_schema.set_store_format(OB_STORE_FORMAT_DYNAMIC_MYSQL);
|
||||
table_schema.set_progressive_merge_round(1);
|
||||
table_schema.set_storage_format_version(3);
|
||||
table_schema.set_tablet_id(0);
|
||||
table_schema.set_micro_index_clustered(false);
|
||||
|
||||
table_schema.set_max_used_column_id(column_id);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObInnerTableSchema::all_virtual_vector_index_info_schema(ObTableSchema &table_schema)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
@ -2515,6 +2515,276 @@ int ObInnerTableSchema::all_virtual_ss_local_cache_info_ora_schema(ObTableSchema
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObInnerTableSchema::all_virtual_spm_evo_result_ora_schema(ObTableSchema &table_schema)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;
|
||||
|
||||
//generated fields:
|
||||
table_schema.set_tenant_id(OB_SYS_TENANT_ID);
|
||||
table_schema.set_tablegroup_id(OB_INVALID_ID);
|
||||
table_schema.set_database_id(OB_ORA_SYS_DATABASE_ID);
|
||||
table_schema.set_table_id(OB_ALL_VIRTUAL_SPM_EVO_RESULT_ORA_TID);
|
||||
table_schema.set_rowkey_split_pos(0);
|
||||
table_schema.set_is_use_bloomfilter(false);
|
||||
table_schema.set_progressive_merge_num(0);
|
||||
table_schema.set_rowkey_column_num(4);
|
||||
table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
|
||||
table_schema.set_table_type(VIRTUAL_TABLE);
|
||||
table_schema.set_index_type(INDEX_TYPE_IS_NOT);
|
||||
table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_FAIL(table_schema.set_table_name(OB_ALL_VIRTUAL_SPM_EVO_RESULT_ORA_TNAME))) {
|
||||
LOG_ERROR("fail to set table_name", K(ret));
|
||||
}
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
|
||||
LOG_ERROR("fail to set compress_func_name", K(ret));
|
||||
}
|
||||
}
|
||||
table_schema.set_part_level(PARTITION_LEVEL_ZERO);
|
||||
table_schema.set_charset_type(ObCharset::get_default_charset());
|
||||
table_schema.set_collation_type(ObCollationType::CS_TYPE_UTF8MB4_BIN);
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("TENANT_ID", //column_name
|
||||
++column_id, //column_id
|
||||
1, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObNumberType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
38, //column_length
|
||||
38, //column_precision
|
||||
0, //column_scale
|
||||
false, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("RECORD_TIME", //column_name
|
||||
++column_id, //column_id
|
||||
2, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObTimestampLTZType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
0, //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
false, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("SVR_IP", //column_name
|
||||
++column_id, //column_id
|
||||
3, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObVarcharType, //column_type
|
||||
CS_TYPE_UTF8MB4_BIN, //column_collation_type
|
||||
MAX_IP_ADDR_LENGTH, //column_length
|
||||
2, //column_precision
|
||||
-1, //column_scale
|
||||
false, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("SVR_PORT", //column_name
|
||||
++column_id, //column_id
|
||||
4, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObNumberType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
38, //column_length
|
||||
38, //column_precision
|
||||
0, //column_scale
|
||||
false, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("DATABASE_ID", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObNumberType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
38, //column_length
|
||||
38, //column_precision
|
||||
0, //column_scale
|
||||
false, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("SQL_ID", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObVarcharType, //column_type
|
||||
CS_TYPE_UTF8MB4_BIN, //column_collation_type
|
||||
OB_MAX_SQL_ID_LENGTH, //column_length
|
||||
2, //column_precision
|
||||
-1, //column_scale
|
||||
false, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("TYPE", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObNumberType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
38, //column_length
|
||||
38, //column_precision
|
||||
0, //column_scale
|
||||
false, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("START_TIME", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObTimestampLTZType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
0, //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
true, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("END_TIME", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObTimestampLTZType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
0, //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
true, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("STATUS", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObVarcharType, //column_type
|
||||
CS_TYPE_UTF8MB4_BIN, //column_collation_type
|
||||
7, //column_length
|
||||
2, //column_precision
|
||||
-1, //column_scale
|
||||
true, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("NEW_PLAN_BETTER", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObNumberType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
38, //column_length
|
||||
38, //column_precision
|
||||
0, //column_scale
|
||||
true, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("EVO_PLAN_EXEC_COUNT", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObNumberType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
38, //column_length
|
||||
38, //column_precision
|
||||
0, //column_scale
|
||||
true, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("EVO_PLAN_CPU_TIME", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObNumberType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
38, //column_length
|
||||
38, //column_precision
|
||||
0, //column_scale
|
||||
true, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("BASELINE_EXEC_COUNT", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObNumberType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
38, //column_length
|
||||
38, //column_precision
|
||||
0, //column_scale
|
||||
true, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("BASELINE_CPU_TIME", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObNumberType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
38, //column_length
|
||||
38, //column_precision
|
||||
0, //column_scale
|
||||
true, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
table_schema.set_index_using_type(USING_BTREE);
|
||||
table_schema.set_row_store_type(ENCODING_ROW_STORE);
|
||||
table_schema.set_store_format(OB_STORE_FORMAT_DYNAMIC_MYSQL);
|
||||
table_schema.set_progressive_merge_round(1);
|
||||
table_schema.set_storage_format_version(3);
|
||||
table_schema.set_tablet_id(0);
|
||||
table_schema.set_micro_index_clustered(false);
|
||||
|
||||
table_schema.set_max_used_column_id(column_id);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObInnerTableSchema::all_virtual_vector_index_info_ora_schema(ObTableSchema &table_schema)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
@ -111,7 +111,7 @@ int ObInnerTableSchema::dba_tab_statistics_schema(ObTableSchema &table_schema)
|
||||
table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_FAIL(table_schema.set_view_definition(R"__(SELECT CAST(DB.DATABASE_NAME AS CHAR(128)) AS OWNER, CAST(V.TABLE_NAME AS CHAR(128)) AS TABLE_NAME, CAST(V.PARTITION_NAME AS CHAR(128)) AS PARTITION_NAME, CAST(V.PARTITION_POSITION AS NUMBER) AS PARTITION_POSITION, CAST(V.SUBPARTITION_NAME AS CHAR(128)) AS SUBPARTITION_NAME, CAST(V.SUBPARTITION_POSITION AS NUMBER) AS SUBPARTITION_POSITION, CAST(V.OBJECT_TYPE AS CHAR(12)) AS OBJECT_TYPE, CAST(STAT.ROW_CNT AS NUMBER) AS NUM_ROWS, CAST(NULL AS NUMBER) AS BLOCKS, CAST(NULL AS NUMBER) AS EMPTY_BLOCKS, CAST(NULL AS NUMBER) AS AVG_SPACE, CAST(NULL AS NUMBER) AS CHAIN_CNT, CAST(STAT.AVG_ROW_LEN AS NUMBER) AS AVG_ROW_LEN, CAST(NULL AS NUMBER) AS AVG_SPACE_FREELIST_BLOCKS, CAST(NULL AS NUMBER) AS NUM_FREELIST_BLOCKS, CAST(NULL AS NUMBER) AS AVG_CACHED_BLOCKS, CAST(NULL AS NUMBER) AS AVG_CACHE_HIT_RATIO, CAST(NULL AS NUMBER) AS IM_IMCU_COUNT, CAST(NULL AS NUMBER) AS IM_BLOCK_COUNT, CAST(NULL AS DATETIME) AS IM_STAT_UPDATE_TIME, CAST(NULL AS NUMBER) AS SCAN_RATE, CAST(STAT.SPARE1 AS NUMBER) AS SAMPLE_SIZE, CAST(STAT.LAST_ANALYZED AS DATETIME(6)) AS LAST_ANALYZED, CAST((CASE STAT.GLOBAL_STATS WHEN 0 THEN 'NO' WHEN 1 THEN 'YES' ELSE NULL END) AS CHAR(3)) AS GLOBAL_STATS, CAST((CASE STAT.USER_STATS WHEN 0 THEN 'NO' WHEN 1 THEN 'YES' ELSE NULL END) AS CHAR(3)) AS USER_STATS, CAST((CASE WHEN STAT.STATTYPE_LOCKED & 15 IS NULL THEN NULL ELSE (CASE STAT.STATTYPE_LOCKED & 15 WHEN 0 THEN NULL WHEN 1 THEN 'DATA' WHEN 2 THEN 'CACHE' ELSE 'ALL' END) END) AS CHAR(5)) AS STATTYPE_LOCKED, CAST((CASE STAT.STALE_STATS WHEN 0 THEN 'NO' WHEN 1 THEN 'YES' ELSE NULL END) AS CHAR(3)) AS STALE_STATS, CAST(NULL AS CHAR(7)) AS SCOPE FROM ( (SELECT CAST(0 AS SIGNED) AS TENANT_ID, DATABASE_ID, TABLE_ID, -2 AS PARTITION_ID, TABLE_NAME, NULL AS PARTITION_NAME, NULL AS SUBPARTITION_NAME, NULL AS PARTITION_POSITION, NULL AS SUBPARTITION_POSITION, 'TABLE' AS OBJECT_TYPE FROM OCEANBASE.__ALL_VIRTUAL_CORE_ALL_TABLE WHERE TENANT_ID = EFFECTIVE_TENANT_ID() AND TABLE_TYPE IN (0,2,3,6,14,15) UNION ALL SELECT TENANT_ID, DATABASE_ID, TABLE_ID, CASE WHEN PART_LEVEL = 0 THEN -2 ELSE -1 END AS PARTITION_ID, TABLE_NAME, NULL AS PARTITION_NAME, NULL AS SUBPARTITION_NAME, NULL AS PARTITION_POSITION, NULL AS SUBPARTITION_POSITION, 'TABLE' AS OBJECT_TYPE FROM oceanbase.__all_table T WHERE T.TABLE_TYPE IN (0,2,3,6,14,15) AND T.TABLE_MODE >> 12 & 15 in (0,1)) UNION ALL SELECT T.TENANT_ID, T.DATABASE_ID, T.TABLE_ID, P.PART_ID, T.TABLE_NAME, P.PART_NAME, NULL, P.PART_IDX + 1, NULL, 'PARTITION' FROM oceanbase.__all_table T JOIN oceanbase.__all_part P ON T.TENANT_ID = P.TENANT_ID AND T.TABLE_ID = P.TABLE_ID WHERE T.TABLE_TYPE IN (0,2,3,6,14,15) AND T.TABLE_MODE >> 12 & 15 in (0,1) AND (P.PARTITION_TYPE = 0 OR P.PARTITION_TYPE IS NULL) UNION ALL SELECT T.TENANT_ID, T.DATABASE_ID, T.TABLE_ID, SP.SUB_PART_ID AS PARTITION_ID, T.TABLE_NAME, P.PART_NAME, SP.SUB_PART_NAME, P.PART_IDX + 1, SP.SUB_PART_IDX + 1, 'SUBPARTITION' FROM oceanbase.__all_table T JOIN oceanbase.__all_part P ON T.TENANT_ID = P.TENANT_ID AND T.TABLE_ID = P.TABLE_ID JOIN oceanbase.__all_sub_part SP ON T.TENANT_ID = SP.TENANT_ID AND T.TABLE_ID = SP.TABLE_ID AND P.PART_ID = SP.PART_ID WHERE T.TABLE_TYPE IN (0,2,3,6,14,15) AND T.TABLE_MODE >> 12 & 15 in (0,1) AND (P.PARTITION_TYPE = 0 OR P.PARTITION_TYPE IS NULL) AND (SP.PARTITION_TYPE = 0 OR SP.PARTITION_TYPE IS NULL) ) V JOIN oceanbase.__all_database DB ON DB.TENANT_ID = V.TENANT_ID AND DB.DATABASE_ID = V.DATABASE_ID AND V.TENANT_ID = 0 LEFT JOIN oceanbase.__all_table_stat STAT ON V.TENANT_ID = STAT.TENANT_ID AND V.TABLE_ID = STAT.TABLE_ID AND (V.PARTITION_ID = STAT.PARTITION_ID OR V.PARTITION_ID = -2) AND STAT.INDEX_TYPE = 0 )__"))) {
|
||||
if (OB_FAIL(table_schema.set_view_definition(R"__(SELECT CAST(DB.DATABASE_NAME AS CHAR(128)) AS OWNER, CAST(V.TABLE_NAME AS CHAR(128)) AS TABLE_NAME, CAST(V.PARTITION_NAME AS CHAR(128)) AS PARTITION_NAME, CAST(V.PARTITION_POSITION AS NUMBER) AS PARTITION_POSITION, CAST(V.SUBPARTITION_NAME AS CHAR(128)) AS SUBPARTITION_NAME, CAST(V.SUBPARTITION_POSITION AS NUMBER) AS SUBPARTITION_POSITION, CAST(V.OBJECT_TYPE AS CHAR(12)) AS OBJECT_TYPE, CAST(STAT.ROW_CNT AS NUMBER) AS NUM_ROWS, CAST(NULL AS NUMBER) AS BLOCKS, CAST(NULL AS NUMBER) AS EMPTY_BLOCKS, CAST(NULL AS NUMBER) AS AVG_SPACE, CAST(NULL AS NUMBER) AS CHAIN_CNT, CAST(STAT.AVG_ROW_LEN AS NUMBER) AS AVG_ROW_LEN, CAST(NULL AS NUMBER) AS AVG_SPACE_FREELIST_BLOCKS, CAST(NULL AS NUMBER) AS NUM_FREELIST_BLOCKS, CAST(NULL AS NUMBER) AS AVG_CACHED_BLOCKS, CAST(NULL AS NUMBER) AS AVG_CACHE_HIT_RATIO, CAST(NULL AS NUMBER) AS IM_IMCU_COUNT, CAST(NULL AS NUMBER) AS IM_BLOCK_COUNT, CAST(NULL AS DATETIME) AS IM_STAT_UPDATE_TIME, CAST(NULL AS NUMBER) AS SCAN_RATE, CAST(STAT.SPARE1 AS DECIMAL(20, 0)) AS SAMPLE_SIZE, CAST(STAT.LAST_ANALYZED AS DATETIME(6)) AS LAST_ANALYZED, CAST((CASE STAT.GLOBAL_STATS WHEN 0 THEN 'NO' WHEN 1 THEN 'YES' ELSE NULL END) AS CHAR(3)) AS GLOBAL_STATS, CAST((CASE STAT.USER_STATS WHEN 0 THEN 'NO' WHEN 1 THEN 'YES' ELSE NULL END) AS CHAR(3)) AS USER_STATS, CAST((CASE WHEN STAT.STATTYPE_LOCKED & 15 IS NULL THEN NULL ELSE (CASE STAT.STATTYPE_LOCKED & 15 WHEN 0 THEN NULL WHEN 1 THEN 'DATA' WHEN 2 THEN 'CACHE' ELSE 'ALL' END) END) AS CHAR(5)) AS STATTYPE_LOCKED, CAST((CASE STAT.STALE_STATS WHEN 0 THEN 'NO' WHEN 1 THEN 'YES' ELSE NULL END) AS CHAR(3)) AS STALE_STATS, CAST(NULL AS CHAR(7)) AS SCOPE FROM ( (SELECT CAST(0 AS SIGNED) AS TENANT_ID, DATABASE_ID, TABLE_ID, -2 AS PARTITION_ID, TABLE_NAME, NULL AS PARTITION_NAME, NULL AS SUBPARTITION_NAME, NULL AS PARTITION_POSITION, NULL AS SUBPARTITION_POSITION, 'TABLE' AS OBJECT_TYPE FROM OCEANBASE.__ALL_VIRTUAL_CORE_ALL_TABLE WHERE TENANT_ID = EFFECTIVE_TENANT_ID() AND TABLE_TYPE IN (0,2,3,6,14,15) UNION ALL SELECT TENANT_ID, DATABASE_ID, TABLE_ID, CASE WHEN PART_LEVEL = 0 THEN -2 ELSE -1 END AS PARTITION_ID, TABLE_NAME, NULL AS PARTITION_NAME, NULL AS SUBPARTITION_NAME, NULL AS PARTITION_POSITION, NULL AS SUBPARTITION_POSITION, 'TABLE' AS OBJECT_TYPE FROM oceanbase.__all_table T WHERE T.TABLE_TYPE IN (0,2,3,6,14,15) AND T.TABLE_MODE >> 12 & 15 in (0,1)) UNION ALL SELECT T.TENANT_ID, T.DATABASE_ID, T.TABLE_ID, P.PART_ID, T.TABLE_NAME, P.PART_NAME, NULL, P.PART_IDX + 1, NULL, 'PARTITION' FROM oceanbase.__all_table T JOIN oceanbase.__all_part P ON T.TENANT_ID = P.TENANT_ID AND T.TABLE_ID = P.TABLE_ID WHERE T.TABLE_TYPE IN (0,2,3,6,14,15) AND T.TABLE_MODE >> 12 & 15 in (0,1) AND (P.PARTITION_TYPE = 0 OR P.PARTITION_TYPE IS NULL) UNION ALL SELECT T.TENANT_ID, T.DATABASE_ID, T.TABLE_ID, SP.SUB_PART_ID AS PARTITION_ID, T.TABLE_NAME, P.PART_NAME, SP.SUB_PART_NAME, P.PART_IDX + 1, SP.SUB_PART_IDX + 1, 'SUBPARTITION' FROM oceanbase.__all_table T JOIN oceanbase.__all_part P ON T.TENANT_ID = P.TENANT_ID AND T.TABLE_ID = P.TABLE_ID JOIN oceanbase.__all_sub_part SP ON T.TENANT_ID = SP.TENANT_ID AND T.TABLE_ID = SP.TABLE_ID AND P.PART_ID = SP.PART_ID WHERE T.TABLE_TYPE IN (0,2,3,6,14,15) AND T.TABLE_MODE >> 12 & 15 in (0,1) AND (P.PARTITION_TYPE = 0 OR P.PARTITION_TYPE IS NULL) AND (SP.PARTITION_TYPE = 0 OR SP.PARTITION_TYPE IS NULL) ) V JOIN oceanbase.__all_database DB ON DB.TENANT_ID = V.TENANT_ID AND DB.DATABASE_ID = V.DATABASE_ID AND V.TENANT_ID = 0 LEFT JOIN oceanbase.__all_table_stat STAT ON V.TENANT_ID = STAT.TENANT_ID AND V.TABLE_ID = STAT.TABLE_ID AND (V.PARTITION_ID = STAT.PARTITION_ID OR V.PARTITION_ID = -2) AND STAT.INDEX_TYPE = 0 )__"))) {
|
||||
LOG_ERROR("fail to set view_definition", K(ret));
|
||||
}
|
||||
}
|
||||
|
@ -433,6 +433,108 @@ int ObInnerTableSchema::v_ob_kv_client_info_schema(ObTableSchema &table_schema)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObInnerTableSchema::dba_ob_spm_evo_result_schema(ObTableSchema &table_schema)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;
|
||||
|
||||
//generated fields:
|
||||
table_schema.set_tenant_id(OB_SYS_TENANT_ID);
|
||||
table_schema.set_tablegroup_id(OB_INVALID_ID);
|
||||
table_schema.set_database_id(OB_SYS_DATABASE_ID);
|
||||
table_schema.set_table_id(OB_DBA_OB_SPM_EVO_RESULT_TID);
|
||||
table_schema.set_rowkey_split_pos(0);
|
||||
table_schema.set_is_use_bloomfilter(false);
|
||||
table_schema.set_progressive_merge_num(0);
|
||||
table_schema.set_rowkey_column_num(0);
|
||||
table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
|
||||
table_schema.set_table_type(SYSTEM_VIEW);
|
||||
table_schema.set_index_type(INDEX_TYPE_IS_NOT);
|
||||
table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_FAIL(table_schema.set_table_name(OB_DBA_OB_SPM_EVO_RESULT_TNAME))) {
|
||||
LOG_ERROR("fail to set table_name", K(ret));
|
||||
}
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
|
||||
LOG_ERROR("fail to set compress_func_name", K(ret));
|
||||
}
|
||||
}
|
||||
table_schema.set_part_level(PARTITION_LEVEL_ZERO);
|
||||
table_schema.set_charset_type(ObCharset::get_default_charset());
|
||||
table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT D.DATABASE_NAME AS OWNER, RECORD_TIME, SVR_IP, SVR_PORT, SQL_ID, CAST(CASE WHEN TYPE = 0 THEN 'OnlineEvolve' WHEN TYPE = 1 THEN 'FirstBaseline' WHEN TYPE = 2 THEN 'UnReproducible' WHEN TYPE = 3 THEN 'BaselineFirst' ELSE NULL END AS CHAR(32)) AS TYPE, START_TIME, END_TIME, STATUS, NEW_PLAN_BETTER, EVO_PLAN_EXEC_COUNT, EVO_PLAN_CPU_TIME, BASELINE_EXEC_COUNT, BASELINE_CPU_TIME FROM OCEANBASE.__ALL_VIRTUAL_SPM_EVO_RESULT R, OCEANBASE.__ALL_DATABASE D WHERE R.TENANT_ID = EFFECTIVE_TENANT_ID() AND D.TENANT_ID = 0 AND R.DATABASE_ID = D.DATABASE_ID )__"))) {
|
||||
LOG_ERROR("fail to set view_definition", K(ret));
|
||||
}
|
||||
}
|
||||
table_schema.set_index_using_type(USING_BTREE);
|
||||
table_schema.set_row_store_type(ENCODING_ROW_STORE);
|
||||
table_schema.set_store_format(OB_STORE_FORMAT_DYNAMIC_MYSQL);
|
||||
table_schema.set_progressive_merge_round(1);
|
||||
table_schema.set_storage_format_version(3);
|
||||
table_schema.set_tablet_id(0);
|
||||
table_schema.set_micro_index_clustered(false);
|
||||
|
||||
table_schema.set_max_used_column_id(column_id);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObInnerTableSchema::cdb_ob_spm_evo_result_schema(ObTableSchema &table_schema)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;
|
||||
|
||||
//generated fields:
|
||||
table_schema.set_tenant_id(OB_SYS_TENANT_ID);
|
||||
table_schema.set_tablegroup_id(OB_INVALID_ID);
|
||||
table_schema.set_database_id(OB_SYS_DATABASE_ID);
|
||||
table_schema.set_table_id(OB_CDB_OB_SPM_EVO_RESULT_TID);
|
||||
table_schema.set_rowkey_split_pos(0);
|
||||
table_schema.set_is_use_bloomfilter(false);
|
||||
table_schema.set_progressive_merge_num(0);
|
||||
table_schema.set_rowkey_column_num(0);
|
||||
table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
|
||||
table_schema.set_table_type(SYSTEM_VIEW);
|
||||
table_schema.set_index_type(INDEX_TYPE_IS_NOT);
|
||||
table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_FAIL(table_schema.set_table_name(OB_CDB_OB_SPM_EVO_RESULT_TNAME))) {
|
||||
LOG_ERROR("fail to set table_name", K(ret));
|
||||
}
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
|
||||
LOG_ERROR("fail to set compress_func_name", K(ret));
|
||||
}
|
||||
}
|
||||
table_schema.set_part_level(PARTITION_LEVEL_ZERO);
|
||||
table_schema.set_charset_type(ObCharset::get_default_charset());
|
||||
table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT R.TENANT_ID, D.DATABASE_NAME AS OWNER, RECORD_TIME, SVR_IP, SVR_PORT, SQL_ID, CAST(CASE WHEN TYPE = 0 THEN 'OnlineEvolve' WHEN TYPE = 1 THEN 'FirstBaseline' WHEN TYPE = 2 THEN 'UnReproducible' WHEN TYPE = 3 THEN 'BaselineFirst' ELSE NULL END AS CHAR(32)) AS TYPE, START_TIME, END_TIME, STATUS, NEW_PLAN_BETTER, EVO_PLAN_EXEC_COUNT, EVO_PLAN_CPU_TIME, BASELINE_EXEC_COUNT, BASELINE_CPU_TIME FROM OCEANBASE.__ALL_VIRTUAL_SPM_EVO_RESULT R, OCEANBASE.__ALL_VIRTUAL_DATABASE D WHERE R.TENANT_ID = D.TENANT_ID AND R.DATABASE_ID = D.DATABASE_ID )__"))) {
|
||||
LOG_ERROR("fail to set view_definition", K(ret));
|
||||
}
|
||||
}
|
||||
table_schema.set_index_using_type(USING_BTREE);
|
||||
table_schema.set_row_store_type(ENCODING_ROW_STORE);
|
||||
table_schema.set_store_format(OB_STORE_FORMAT_DYNAMIC_MYSQL);
|
||||
table_schema.set_progressive_merge_round(1);
|
||||
table_schema.set_storage_format_version(3);
|
||||
table_schema.set_tablet_id(0);
|
||||
table_schema.set_micro_index_clustered(false);
|
||||
|
||||
table_schema.set_max_used_column_id(column_id);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObInnerTableSchema::gv_ob_function_io_stat_schema(ObTableSchema &table_schema)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
@ -25,6 +25,57 @@ using namespace common;
|
||||
namespace share
|
||||
{
|
||||
|
||||
int ObInnerTableSchema::dba_ob_spm_evo_result_ora_schema(ObTableSchema &table_schema)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;
|
||||
|
||||
//generated fields:
|
||||
table_schema.set_tenant_id(OB_SYS_TENANT_ID);
|
||||
table_schema.set_tablegroup_id(OB_INVALID_ID);
|
||||
table_schema.set_database_id(OB_ORA_SYS_DATABASE_ID);
|
||||
table_schema.set_table_id(OB_DBA_OB_SPM_EVO_RESULT_ORA_TID);
|
||||
table_schema.set_rowkey_split_pos(0);
|
||||
table_schema.set_is_use_bloomfilter(false);
|
||||
table_schema.set_progressive_merge_num(0);
|
||||
table_schema.set_rowkey_column_num(0);
|
||||
table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
|
||||
table_schema.set_table_type(SYSTEM_VIEW);
|
||||
table_schema.set_index_type(INDEX_TYPE_IS_NOT);
|
||||
table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_FAIL(table_schema.set_table_name(OB_DBA_OB_SPM_EVO_RESULT_ORA_TNAME))) {
|
||||
LOG_ERROR("fail to set table_name", K(ret));
|
||||
}
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
|
||||
LOG_ERROR("fail to set compress_func_name", K(ret));
|
||||
}
|
||||
}
|
||||
table_schema.set_part_level(PARTITION_LEVEL_ZERO);
|
||||
table_schema.set_charset_type(ObCharset::get_default_charset());
|
||||
table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT D.DATABASE_NAME AS OWNER, RECORD_TIME, SVR_IP, SVR_PORT, SQL_ID, CAST(CASE WHEN TYPE = 0 THEN 'OnlineEvolve' WHEN TYPE = 1 THEN 'FirstBaseline' WHEN TYPE = 2 THEN 'UnReproducible' WHEN TYPE = 3 THEN 'BaselineFirst' ELSE NULL END AS VARCHAR(32)) AS TYPE, START_TIME, END_TIME, STATUS, NEW_PLAN_BETTER, EVO_PLAN_EXEC_COUNT, EVO_PLAN_CPU_TIME, BASELINE_EXEC_COUNT, BASELINE_CPU_TIME FROM SYS.ALL_VIRTUAL_SPM_EVO_RESULT R, SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT D WHERE R.TENANT_ID = EFFECTIVE_TENANT_ID() AND D.TENANT_ID = EFFECTIVE_TENANT_ID() AND R.DATABASE_ID = D.DATABASE_ID )__"))) {
|
||||
LOG_ERROR("fail to set view_definition", K(ret));
|
||||
}
|
||||
}
|
||||
table_schema.set_index_using_type(USING_BTREE);
|
||||
table_schema.set_row_store_type(ENCODING_ROW_STORE);
|
||||
table_schema.set_store_format(OB_STORE_FORMAT_DYNAMIC_MYSQL);
|
||||
table_schema.set_progressive_merge_round(1);
|
||||
table_schema.set_storage_format_version(3);
|
||||
table_schema.set_tablet_id(0);
|
||||
table_schema.set_micro_index_clustered(false);
|
||||
|
||||
table_schema.set_max_used_column_id(column_id);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObInnerTableSchema::gv_ob_function_io_stat_ora_schema(ObTableSchema &table_schema)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
@ -3795,6 +3795,281 @@ int ObInnerTableSchema::all_scheduler_job_run_detail_v2_schema(ObTableSchema &ta
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObInnerTableSchema::all_spm_evo_result_schema(ObTableSchema &table_schema)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;
|
||||
|
||||
//generated fields:
|
||||
table_schema.set_tenant_id(OB_SYS_TENANT_ID);
|
||||
table_schema.set_tablegroup_id(OB_SYS_TABLEGROUP_ID);
|
||||
table_schema.set_database_id(OB_SYS_DATABASE_ID);
|
||||
table_schema.set_table_id(OB_ALL_SPM_EVO_RESULT_TID);
|
||||
table_schema.set_rowkey_split_pos(0);
|
||||
table_schema.set_is_use_bloomfilter(false);
|
||||
table_schema.set_progressive_merge_num(0);
|
||||
table_schema.set_rowkey_column_num(4);
|
||||
table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
|
||||
table_schema.set_table_type(SYSTEM_TABLE);
|
||||
table_schema.set_index_type(INDEX_TYPE_IS_NOT);
|
||||
table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_FAIL(table_schema.set_table_name(OB_ALL_SPM_EVO_RESULT_TNAME))) {
|
||||
LOG_ERROR("fail to set table_name", K(ret));
|
||||
}
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
|
||||
LOG_ERROR("fail to set compress_func_name", K(ret));
|
||||
}
|
||||
}
|
||||
table_schema.set_part_level(PARTITION_LEVEL_ZERO);
|
||||
table_schema.set_charset_type(ObCharset::get_default_charset());
|
||||
table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("tenant_id", //column_name
|
||||
++column_id, //column_id
|
||||
1, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObIntType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
sizeof(int64_t), //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
false, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA_TS("record_time", //column_name
|
||||
++column_id, //column_id
|
||||
2, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObTimestampType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
sizeof(ObPreciseDateTime), //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
false, //is_nullable
|
||||
false, //is_autoincrement
|
||||
false); //is_on_update_for_timestamp
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("svr_ip", //column_name
|
||||
++column_id, //column_id
|
||||
3, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObVarcharType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
MAX_IP_ADDR_LENGTH, //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
false, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("svr_port", //column_name
|
||||
++column_id, //column_id
|
||||
4, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObIntType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
sizeof(int64_t), //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
false, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("database_id", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObIntType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
sizeof(int64_t), //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
false, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("sql_id", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObVarcharType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
OB_MAX_SQL_ID_LENGTH, //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
false, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("type", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObIntType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
sizeof(int64_t), //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
false, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA_TS("start_time", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObTimestampType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
sizeof(ObPreciseDateTime), //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
true, //is_nullable
|
||||
false, //is_autoincrement
|
||||
false); //is_on_update_for_timestamp
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA_TS("end_time", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObTimestampType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
sizeof(ObPreciseDateTime), //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
true, //is_nullable
|
||||
false, //is_autoincrement
|
||||
false); //is_on_update_for_timestamp
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("status", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObVarcharType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
7, //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
true, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("new_plan_better", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObTinyIntType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
1, //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
true, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("evo_plan_exec_count", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObIntType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
sizeof(int64_t), //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
true, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("evo_plan_cpu_time", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObIntType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
sizeof(int64_t), //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
true, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("baseline_exec_count", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObIntType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
sizeof(int64_t), //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
true, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("baseline_cpu_time", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObIntType, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
sizeof(int64_t), //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
true, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
table_schema.set_index_using_type(USING_BTREE);
|
||||
table_schema.set_row_store_type(ENCODING_ROW_STORE);
|
||||
table_schema.set_store_format(OB_STORE_FORMAT_DYNAMIC_MYSQL);
|
||||
table_schema.set_progressive_merge_round(1);
|
||||
table_schema.set_storage_format_version(3);
|
||||
table_schema.set_tablet_id(OB_ALL_SPM_EVO_RESULT_TID);
|
||||
table_schema.set_micro_index_clustered(false);
|
||||
table_schema.set_aux_lob_meta_tid(OB_ALL_SPM_EVO_RESULT_AUX_LOB_META_TID);
|
||||
table_schema.set_aux_lob_piece_tid(OB_ALL_SPM_EVO_RESULT_AUX_LOB_PIECE_TID);
|
||||
|
||||
table_schema.set_max_used_column_id(column_id);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObInnerTableSchema::all_ncomp_dll_v2_schema(ObTableSchema &table_schema)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
@ -2337,6 +2337,142 @@ int ObInnerTableSchema::all_scheduler_job_run_detail_v2_aux_lob_meta_schema(ObTa
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObInnerTableSchema::all_spm_evo_result_aux_lob_meta_schema(ObTableSchema &table_schema)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;
|
||||
|
||||
//generated fields:
|
||||
table_schema.set_tenant_id(OB_SYS_TENANT_ID);
|
||||
table_schema.set_tablegroup_id(OB_SYS_TABLEGROUP_ID);
|
||||
table_schema.set_database_id(OB_SYS_DATABASE_ID);
|
||||
table_schema.set_table_id(OB_ALL_SPM_EVO_RESULT_AUX_LOB_META_TID);
|
||||
table_schema.set_rowkey_split_pos(0);
|
||||
table_schema.set_is_use_bloomfilter(false);
|
||||
table_schema.set_progressive_merge_num(0);
|
||||
table_schema.set_rowkey_column_num(2);
|
||||
table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
|
||||
table_schema.set_table_type(AUX_LOB_META);
|
||||
table_schema.set_index_type(INDEX_TYPE_IS_NOT);
|
||||
table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_FAIL(table_schema.set_table_name(OB_ALL_SPM_EVO_RESULT_AUX_LOB_META_TNAME))) {
|
||||
LOG_ERROR("fail to set table_name", K(ret));
|
||||
}
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
|
||||
LOG_ERROR("fail to set compress_func_name", K(ret));
|
||||
}
|
||||
}
|
||||
table_schema.set_part_level(PARTITION_LEVEL_ZERO);
|
||||
table_schema.set_charset_type(ObCharset::get_default_charset());
|
||||
table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("lob_id", //column_name
|
||||
++column_id, //column_id
|
||||
1, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObVarcharType, //column_type
|
||||
CS_TYPE_BINARY, //column_collation_type
|
||||
16, //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
false, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("seq_id", //column_name
|
||||
++column_id, //column_id
|
||||
2, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObVarcharType, //column_type
|
||||
CS_TYPE_BINARY, //column_collation_type
|
||||
8192, //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
false, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("binary_len", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObUInt32Type, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
sizeof(uint32_t), //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
false, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("char_len", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObUInt32Type, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
sizeof(uint32_t), //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
false, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("piece_id", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObUInt64Type, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
sizeof(uint64_t), //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
false, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("lob_data", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObVarcharType, //column_type
|
||||
CS_TYPE_BINARY, //column_collation_type
|
||||
262144, //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
false, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
table_schema.set_index_using_type(USING_BTREE);
|
||||
table_schema.set_row_store_type(ENCODING_ROW_STORE);
|
||||
table_schema.set_store_format(OB_STORE_FORMAT_DYNAMIC_MYSQL);
|
||||
table_schema.set_progressive_merge_round(1);
|
||||
table_schema.set_storage_format_version(3);
|
||||
table_schema.set_tablet_id(OB_ALL_SPM_EVO_RESULT_AUX_LOB_META_TID);
|
||||
table_schema.set_micro_index_clustered(false);
|
||||
table_schema.set_data_table_id(OB_ALL_SPM_EVO_RESULT_TID);
|
||||
|
||||
table_schema.set_max_used_column_id(column_id);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObInnerTableSchema::all_ncomp_dll_v2_aux_lob_meta_schema(ObTableSchema &table_schema)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
@ -1572,6 +1572,97 @@ int ObInnerTableSchema::all_scheduler_job_run_detail_v2_aux_lob_piece_schema(ObT
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObInnerTableSchema::all_spm_evo_result_aux_lob_piece_schema(ObTableSchema &table_schema)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;
|
||||
|
||||
//generated fields:
|
||||
table_schema.set_tenant_id(OB_SYS_TENANT_ID);
|
||||
table_schema.set_tablegroup_id(OB_SYS_TABLEGROUP_ID);
|
||||
table_schema.set_database_id(OB_SYS_DATABASE_ID);
|
||||
table_schema.set_table_id(OB_ALL_SPM_EVO_RESULT_AUX_LOB_PIECE_TID);
|
||||
table_schema.set_rowkey_split_pos(0);
|
||||
table_schema.set_is_use_bloomfilter(false);
|
||||
table_schema.set_progressive_merge_num(0);
|
||||
table_schema.set_rowkey_column_num(1);
|
||||
table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
|
||||
table_schema.set_table_type(AUX_LOB_PIECE);
|
||||
table_schema.set_index_type(INDEX_TYPE_IS_NOT);
|
||||
table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_FAIL(table_schema.set_table_name(OB_ALL_SPM_EVO_RESULT_AUX_LOB_PIECE_TNAME))) {
|
||||
LOG_ERROR("fail to set table_name", K(ret));
|
||||
}
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
|
||||
LOG_ERROR("fail to set compress_func_name", K(ret));
|
||||
}
|
||||
}
|
||||
table_schema.set_part_level(PARTITION_LEVEL_ZERO);
|
||||
table_schema.set_charset_type(ObCharset::get_default_charset());
|
||||
table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("piece_id", //column_name
|
||||
++column_id, //column_id
|
||||
1, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObUInt64Type, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
sizeof(uint64_t), //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
false, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("data_len", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObUInt32Type, //column_type
|
||||
CS_TYPE_INVALID, //column_collation_type
|
||||
sizeof(uint32_t), //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
false, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
ADD_COLUMN_SCHEMA("lob_data", //column_name
|
||||
++column_id, //column_id
|
||||
0, //rowkey_id
|
||||
0, //index_id
|
||||
0, //part_key_pos
|
||||
ObVarcharType, //column_type
|
||||
CS_TYPE_BINARY, //column_collation_type
|
||||
32, //column_length
|
||||
-1, //column_precision
|
||||
-1, //column_scale
|
||||
false, //is_nullable
|
||||
false); //is_autoincrement
|
||||
}
|
||||
table_schema.set_index_using_type(USING_BTREE);
|
||||
table_schema.set_row_store_type(ENCODING_ROW_STORE);
|
||||
table_schema.set_store_format(OB_STORE_FORMAT_DYNAMIC_MYSQL);
|
||||
table_schema.set_progressive_merge_round(1);
|
||||
table_schema.set_storage_format_version(3);
|
||||
table_schema.set_tablet_id(OB_ALL_SPM_EVO_RESULT_AUX_LOB_PIECE_TID);
|
||||
table_schema.set_micro_index_clustered(false);
|
||||
table_schema.set_data_table_id(OB_ALL_SPM_EVO_RESULT_TID);
|
||||
|
||||
table_schema.set_max_used_column_id(column_id);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObInnerTableSchema::all_ncomp_dll_v2_aux_lob_piece_schema(ObTableSchema &table_schema)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
@ -636,6 +636,7 @@ public:
|
||||
static int all_storage_io_usage_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int all_mview_dep_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int all_scheduler_job_run_detail_v2_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int all_spm_evo_result_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int all_ncomp_dll_v2_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int tenant_virtual_all_table_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int tenant_virtual_table_column_schema(share::schema::ObTableSchema &table_schema);
|
||||
@ -1108,6 +1109,7 @@ public:
|
||||
static int all_virtual_log_transport_dest_stat_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int all_virtual_ss_local_cache_info_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int all_virtual_kv_group_commit_status_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int all_virtual_spm_evo_result_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int all_virtual_vector_index_info_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int all_virtual_kv_client_info_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int all_virtual_function_io_stat_schema(share::schema::ObTableSchema &table_schema);
|
||||
@ -1395,6 +1397,7 @@ public:
|
||||
static int all_virtual_spatial_reference_systems_real_agent_ora_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int all_virtual_log_transport_dest_stat_ora_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int all_virtual_ss_local_cache_info_ora_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int all_virtual_spm_evo_result_ora_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int all_virtual_vector_index_info_ora_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int all_virtual_function_io_stat_ora_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int all_virtual_temp_file_ora_schema(share::schema::ObTableSchema &table_schema);
|
||||
@ -1888,6 +1891,8 @@ public:
|
||||
static int innodb_sys_foreign_cols_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int gv_ob_kv_client_info_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int v_ob_kv_client_info_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int dba_ob_spm_evo_result_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int cdb_ob_spm_evo_result_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int gv_ob_function_io_stat_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int v_ob_function_io_stat_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int dba_ob_temp_files_schema(share::schema::ObTableSchema &table_schema);
|
||||
@ -2372,6 +2377,7 @@ public:
|
||||
static int v_ob_log_transport_dest_stat_ora_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int gv_ob_ss_local_cache_ora_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int v_ob_ss_local_cache_ora_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int dba_ob_spm_evo_result_ora_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int gv_ob_function_io_stat_ora_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int v_ob_function_io_stat_ora_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int dba_ob_temp_files_ora_schema(share::schema::ObTableSchema &table_schema);
|
||||
@ -2683,6 +2689,7 @@ public:
|
||||
static int all_storage_io_usage_aux_lob_meta_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int all_mview_dep_aux_lob_meta_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int all_scheduler_job_run_detail_v2_aux_lob_meta_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int all_spm_evo_result_aux_lob_meta_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int all_ncomp_dll_v2_aux_lob_meta_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int all_table_aux_lob_piece_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int all_column_aux_lob_piece_schema(share::schema::ObTableSchema &table_schema);
|
||||
@ -2992,6 +2999,7 @@ public:
|
||||
static int all_storage_io_usage_aux_lob_piece_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int all_mview_dep_aux_lob_piece_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int all_scheduler_job_run_detail_v2_aux_lob_piece_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int all_spm_evo_result_aux_lob_piece_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int all_ncomp_dll_v2_aux_lob_piece_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int all_virtual_ash_all_virtual_ash_i1_schema(share::schema::ObTableSchema &table_schema);
|
||||
static int all_virtual_sql_plan_monitor_all_virtual_sql_plan_monitor_i1_schema(share::schema::ObTableSchema &table_schema);
|
||||
@ -3522,6 +3530,7 @@ const schema_create_func sys_table_schema_creators [] = {
|
||||
ObInnerTableSchema::all_storage_io_usage_schema,
|
||||
ObInnerTableSchema::all_mview_dep_schema,
|
||||
ObInnerTableSchema::all_scheduler_job_run_detail_v2_schema,
|
||||
ObInnerTableSchema::all_spm_evo_result_schema,
|
||||
ObInnerTableSchema::all_ncomp_dll_v2_schema,
|
||||
NULL,};
|
||||
|
||||
@ -3997,6 +4006,7 @@ const schema_create_func virtual_table_schema_creators [] = {
|
||||
ObInnerTableSchema::all_virtual_log_transport_dest_stat_schema,
|
||||
ObInnerTableSchema::all_virtual_ss_local_cache_info_schema,
|
||||
ObInnerTableSchema::all_virtual_kv_group_commit_status_schema,
|
||||
ObInnerTableSchema::all_virtual_spm_evo_result_schema,
|
||||
ObInnerTableSchema::all_virtual_vector_index_info_schema,
|
||||
ObInnerTableSchema::all_virtual_kv_client_info_schema,
|
||||
ObInnerTableSchema::all_virtual_function_io_stat_schema,
|
||||
@ -4294,6 +4304,7 @@ const schema_create_func virtual_table_schema_creators [] = {
|
||||
ObInnerTableSchema::all_virtual_spatial_reference_systems_real_agent_ora_schema,
|
||||
ObInnerTableSchema::all_virtual_log_transport_dest_stat_ora_schema,
|
||||
ObInnerTableSchema::all_virtual_ss_local_cache_info_ora_schema,
|
||||
ObInnerTableSchema::all_virtual_spm_evo_result_ora_schema,
|
||||
ObInnerTableSchema::all_virtual_vector_index_info_ora_schema,
|
||||
ObInnerTableSchema::all_virtual_function_io_stat_ora_schema,
|
||||
ObInnerTableSchema::all_virtual_temp_file_ora_schema,
|
||||
@ -4874,6 +4885,8 @@ const schema_create_func sys_view_schema_creators [] = {
|
||||
ObInnerTableSchema::innodb_sys_foreign_cols_schema,
|
||||
ObInnerTableSchema::gv_ob_kv_client_info_schema,
|
||||
ObInnerTableSchema::v_ob_kv_client_info_schema,
|
||||
ObInnerTableSchema::dba_ob_spm_evo_result_schema,
|
||||
ObInnerTableSchema::cdb_ob_spm_evo_result_schema,
|
||||
ObInnerTableSchema::gv_ob_function_io_stat_schema,
|
||||
ObInnerTableSchema::v_ob_function_io_stat_schema,
|
||||
ObInnerTableSchema::dba_ob_temp_files_schema,
|
||||
@ -5358,6 +5371,7 @@ const schema_create_func sys_view_schema_creators [] = {
|
||||
ObInnerTableSchema::v_ob_log_transport_dest_stat_ora_schema,
|
||||
ObInnerTableSchema::gv_ob_ss_local_cache_ora_schema,
|
||||
ObInnerTableSchema::v_ob_ss_local_cache_ora_schema,
|
||||
ObInnerTableSchema::dba_ob_spm_evo_result_ora_schema,
|
||||
ObInnerTableSchema::gv_ob_function_io_stat_ora_schema,
|
||||
ObInnerTableSchema::v_ob_function_io_stat_ora_schema,
|
||||
ObInnerTableSchema::dba_ob_temp_files_ora_schema,
|
||||
@ -5771,6 +5785,7 @@ const uint64_t tenant_space_tables [] = {
|
||||
OB_ALL_STORAGE_IO_USAGE_TID,
|
||||
OB_ALL_MVIEW_DEP_TID,
|
||||
OB_ALL_SCHEDULER_JOB_RUN_DETAIL_V2_TID,
|
||||
OB_ALL_SPM_EVO_RESULT_TID,
|
||||
OB_ALL_NCOMP_DLL_V2_TID,
|
||||
OB_TENANT_VIRTUAL_ALL_TABLE_TID,
|
||||
OB_TENANT_VIRTUAL_TABLE_COLUMN_TID,
|
||||
@ -6017,6 +6032,7 @@ const uint64_t tenant_space_tables [] = {
|
||||
OB_ALL_VIRTUAL_LOG_TRANSPORT_DEST_STAT_TID,
|
||||
OB_ALL_VIRTUAL_SS_LOCAL_CACHE_INFO_TID,
|
||||
OB_ALL_VIRTUAL_KV_GROUP_COMMIT_STATUS_TID,
|
||||
OB_ALL_VIRTUAL_SPM_EVO_RESULT_TID,
|
||||
OB_ALL_VIRTUAL_VECTOR_INDEX_INFO_TID,
|
||||
OB_ALL_VIRTUAL_KV_CLIENT_INFO_TID,
|
||||
OB_ALL_VIRTUAL_FUNCTION_IO_STAT_TID,
|
||||
@ -6312,6 +6328,7 @@ const uint64_t tenant_space_tables [] = {
|
||||
OB_ALL_VIRTUAL_SPATIAL_REFERENCE_SYSTEMS_REAL_AGENT_ORA_TID,
|
||||
OB_ALL_VIRTUAL_LOG_TRANSPORT_DEST_STAT_ORA_TID,
|
||||
OB_ALL_VIRTUAL_SS_LOCAL_CACHE_INFO_ORA_TID,
|
||||
OB_ALL_VIRTUAL_SPM_EVO_RESULT_ORA_TID,
|
||||
OB_ALL_VIRTUAL_VECTOR_INDEX_INFO_ORA_TID,
|
||||
OB_ALL_VIRTUAL_FUNCTION_IO_STAT_ORA_TID,
|
||||
OB_ALL_VIRTUAL_TEMP_FILE_ORA_TID,
|
||||
@ -6675,6 +6692,7 @@ const uint64_t tenant_space_tables [] = {
|
||||
OB_INNODB_SYS_FOREIGN_COLS_TID,
|
||||
OB_GV_OB_KV_CLIENT_INFO_TID,
|
||||
OB_V_OB_KV_CLIENT_INFO_TID,
|
||||
OB_DBA_OB_SPM_EVO_RESULT_TID,
|
||||
OB_GV_OB_FUNCTION_IO_STAT_TID,
|
||||
OB_V_OB_FUNCTION_IO_STAT_TID,
|
||||
OB_DBA_OB_TEMP_FILES_TID,
|
||||
@ -7158,6 +7176,7 @@ const uint64_t tenant_space_tables [] = {
|
||||
OB_V_OB_LOG_TRANSPORT_DEST_STAT_ORA_TID,
|
||||
OB_GV_OB_SS_LOCAL_CACHE_ORA_TID,
|
||||
OB_V_OB_SS_LOCAL_CACHE_ORA_TID,
|
||||
OB_DBA_OB_SPM_EVO_RESULT_ORA_TID,
|
||||
OB_GV_OB_FUNCTION_IO_STAT_ORA_TID,
|
||||
OB_V_OB_FUNCTION_IO_STAT_ORA_TID,
|
||||
OB_DBA_OB_TEMP_FILES_ORA_TID,
|
||||
@ -7624,6 +7643,7 @@ const uint64_t tenant_space_tables [] = {
|
||||
OB_ALL_STORAGE_IO_USAGE_AUX_LOB_META_TID,
|
||||
OB_ALL_MVIEW_DEP_AUX_LOB_META_TID,
|
||||
OB_ALL_SCHEDULER_JOB_RUN_DETAIL_V2_AUX_LOB_META_TID,
|
||||
OB_ALL_SPM_EVO_RESULT_AUX_LOB_META_TID,
|
||||
OB_ALL_NCOMP_DLL_V2_AUX_LOB_META_TID,
|
||||
OB_ALL_TABLE_AUX_LOB_PIECE_TID,
|
||||
OB_ALL_COLUMN_AUX_LOB_PIECE_TID,
|
||||
@ -7907,6 +7927,7 @@ const uint64_t tenant_space_tables [] = {
|
||||
OB_ALL_STORAGE_IO_USAGE_AUX_LOB_PIECE_TID,
|
||||
OB_ALL_MVIEW_DEP_AUX_LOB_PIECE_TID,
|
||||
OB_ALL_SCHEDULER_JOB_RUN_DETAIL_V2_AUX_LOB_PIECE_TID,
|
||||
OB_ALL_SPM_EVO_RESULT_AUX_LOB_PIECE_TID,
|
||||
OB_ALL_NCOMP_DLL_V2_AUX_LOB_PIECE_TID, };
|
||||
|
||||
const uint64_t all_ora_mapping_virtual_table_org_tables [] = {
|
||||
@ -8063,6 +8084,7 @@ const uint64_t all_ora_mapping_virtual_table_org_tables [] = {
|
||||
OB_ALL_VIRTUAL_NIC_INFO_TID,
|
||||
OB_ALL_VIRTUAL_LOG_TRANSPORT_DEST_STAT_TID,
|
||||
OB_ALL_VIRTUAL_SS_LOCAL_CACHE_INFO_TID,
|
||||
OB_ALL_VIRTUAL_SPM_EVO_RESULT_TID,
|
||||
OB_ALL_VIRTUAL_VECTOR_INDEX_INFO_TID,
|
||||
OB_ALL_VIRTUAL_FUNCTION_IO_STAT_TID,
|
||||
OB_ALL_VIRTUAL_TEMP_FILE_TID,
|
||||
@ -8221,6 +8243,7 @@ const uint64_t all_ora_mapping_virtual_tables [] = { OB_ALL_VIRTUAL_SQL_AUDIT_O
|
||||
, OB_ALL_VIRTUAL_NIC_INFO_ORA_TID
|
||||
, OB_ALL_VIRTUAL_LOG_TRANSPORT_DEST_STAT_ORA_TID
|
||||
, OB_ALL_VIRTUAL_SS_LOCAL_CACHE_INFO_ORA_TID
|
||||
, OB_ALL_VIRTUAL_SPM_EVO_RESULT_ORA_TID
|
||||
, OB_ALL_VIRTUAL_VECTOR_INDEX_INFO_ORA_TID
|
||||
, OB_ALL_VIRTUAL_FUNCTION_IO_STAT_ORA_TID
|
||||
, OB_ALL_VIRTUAL_TEMP_FILE_ORA_TID
|
||||
@ -8522,6 +8545,7 @@ const char* const tenant_space_table_names [] = {
|
||||
OB_ALL_STORAGE_IO_USAGE_TNAME,
|
||||
OB_ALL_MVIEW_DEP_TNAME,
|
||||
OB_ALL_SCHEDULER_JOB_RUN_DETAIL_V2_TNAME,
|
||||
OB_ALL_SPM_EVO_RESULT_TNAME,
|
||||
OB_ALL_NCOMP_DLL_V2_TNAME,
|
||||
OB_TENANT_VIRTUAL_ALL_TABLE_TNAME,
|
||||
OB_TENANT_VIRTUAL_TABLE_COLUMN_TNAME,
|
||||
@ -8768,6 +8792,7 @@ const char* const tenant_space_table_names [] = {
|
||||
OB_ALL_VIRTUAL_LOG_TRANSPORT_DEST_STAT_TNAME,
|
||||
OB_ALL_VIRTUAL_SS_LOCAL_CACHE_INFO_TNAME,
|
||||
OB_ALL_VIRTUAL_KV_GROUP_COMMIT_STATUS_TNAME,
|
||||
OB_ALL_VIRTUAL_SPM_EVO_RESULT_TNAME,
|
||||
OB_ALL_VIRTUAL_VECTOR_INDEX_INFO_TNAME,
|
||||
OB_ALL_VIRTUAL_KV_CLIENT_INFO_TNAME,
|
||||
OB_ALL_VIRTUAL_FUNCTION_IO_STAT_TNAME,
|
||||
@ -9063,6 +9088,7 @@ const char* const tenant_space_table_names [] = {
|
||||
OB_ALL_VIRTUAL_SPATIAL_REFERENCE_SYSTEMS_REAL_AGENT_ORA_TNAME,
|
||||
OB_ALL_VIRTUAL_LOG_TRANSPORT_DEST_STAT_ORA_TNAME,
|
||||
OB_ALL_VIRTUAL_SS_LOCAL_CACHE_INFO_ORA_TNAME,
|
||||
OB_ALL_VIRTUAL_SPM_EVO_RESULT_ORA_TNAME,
|
||||
OB_ALL_VIRTUAL_VECTOR_INDEX_INFO_ORA_TNAME,
|
||||
OB_ALL_VIRTUAL_FUNCTION_IO_STAT_ORA_TNAME,
|
||||
OB_ALL_VIRTUAL_TEMP_FILE_ORA_TNAME,
|
||||
@ -9426,6 +9452,7 @@ const char* const tenant_space_table_names [] = {
|
||||
OB_INNODB_SYS_FOREIGN_COLS_TNAME,
|
||||
OB_GV_OB_KV_CLIENT_INFO_TNAME,
|
||||
OB_V_OB_KV_CLIENT_INFO_TNAME,
|
||||
OB_DBA_OB_SPM_EVO_RESULT_TNAME,
|
||||
OB_GV_OB_FUNCTION_IO_STAT_TNAME,
|
||||
OB_V_OB_FUNCTION_IO_STAT_TNAME,
|
||||
OB_DBA_OB_TEMP_FILES_TNAME,
|
||||
@ -9909,6 +9936,7 @@ const char* const tenant_space_table_names [] = {
|
||||
OB_V_OB_LOG_TRANSPORT_DEST_STAT_ORA_TNAME,
|
||||
OB_GV_OB_SS_LOCAL_CACHE_ORA_TNAME,
|
||||
OB_V_OB_SS_LOCAL_CACHE_ORA_TNAME,
|
||||
OB_DBA_OB_SPM_EVO_RESULT_ORA_TNAME,
|
||||
OB_GV_OB_FUNCTION_IO_STAT_ORA_TNAME,
|
||||
OB_V_OB_FUNCTION_IO_STAT_ORA_TNAME,
|
||||
OB_DBA_OB_TEMP_FILES_ORA_TNAME,
|
||||
@ -10375,6 +10403,7 @@ const char* const tenant_space_table_names [] = {
|
||||
OB_ALL_STORAGE_IO_USAGE_AUX_LOB_META_TNAME,
|
||||
OB_ALL_MVIEW_DEP_AUX_LOB_META_TNAME,
|
||||
OB_ALL_SCHEDULER_JOB_RUN_DETAIL_V2_AUX_LOB_META_TNAME,
|
||||
OB_ALL_SPM_EVO_RESULT_AUX_LOB_META_TNAME,
|
||||
OB_ALL_NCOMP_DLL_V2_AUX_LOB_META_TNAME,
|
||||
OB_ALL_TABLE_AUX_LOB_PIECE_TNAME,
|
||||
OB_ALL_COLUMN_AUX_LOB_PIECE_TNAME,
|
||||
@ -10658,6 +10687,7 @@ const char* const tenant_space_table_names [] = {
|
||||
OB_ALL_STORAGE_IO_USAGE_AUX_LOB_PIECE_TNAME,
|
||||
OB_ALL_MVIEW_DEP_AUX_LOB_PIECE_TNAME,
|
||||
OB_ALL_SCHEDULER_JOB_RUN_DETAIL_V2_AUX_LOB_PIECE_TNAME,
|
||||
OB_ALL_SPM_EVO_RESULT_AUX_LOB_PIECE_TNAME,
|
||||
OB_ALL_NCOMP_DLL_V2_AUX_LOB_PIECE_TNAME, };
|
||||
|
||||
const uint64_t only_rs_vtables [] = {
|
||||
@ -13663,6 +13693,14 @@ LOBMapping const lob_aux_table_mappings [] = {
|
||||
ObInnerTableSchema::all_scheduler_job_run_detail_v2_aux_lob_piece_schema
|
||||
},
|
||||
|
||||
{
|
||||
OB_ALL_SPM_EVO_RESULT_TID,
|
||||
OB_ALL_SPM_EVO_RESULT_AUX_LOB_META_TID,
|
||||
OB_ALL_SPM_EVO_RESULT_AUX_LOB_PIECE_TID,
|
||||
ObInnerTableSchema::all_spm_evo_result_aux_lob_meta_schema,
|
||||
ObInnerTableSchema::all_spm_evo_result_aux_lob_piece_schema
|
||||
},
|
||||
|
||||
{
|
||||
OB_ALL_NCOMP_DLL_V2_TID,
|
||||
OB_ALL_NCOMP_DLL_V2_AUX_LOB_META_TID,
|
||||
@ -13708,12 +13746,12 @@ static inline int get_sys_table_lob_aux_schema(const uint64_t tid,
|
||||
}
|
||||
|
||||
const int64_t OB_CORE_TABLE_COUNT = 4;
|
||||
const int64_t OB_SYS_TABLE_COUNT = 306;
|
||||
const int64_t OB_VIRTUAL_TABLE_COUNT = 857;
|
||||
const int64_t OB_SYS_VIEW_COUNT = 975;
|
||||
const int64_t OB_SYS_TENANT_TABLE_COUNT = 2143;
|
||||
const int64_t OB_SYS_TABLE_COUNT = 307;
|
||||
const int64_t OB_VIRTUAL_TABLE_COUNT = 859;
|
||||
const int64_t OB_SYS_VIEW_COUNT = 978;
|
||||
const int64_t OB_SYS_TENANT_TABLE_COUNT = 2149;
|
||||
const int64_t OB_CORE_SCHEMA_VERSION = 1;
|
||||
const int64_t OB_BOOTSTRAP_SCHEMA_VERSION = 2146;
|
||||
const int64_t OB_BOOTSTRAP_SCHEMA_VERSION = 2152;
|
||||
|
||||
} // end namespace share
|
||||
} // end namespace oceanbase
|
||||
|
@ -21,7 +21,7 @@ inner_lob_map_t inner_lob_map;
|
||||
bool lob_mapping_init()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_FAIL(inner_lob_map.create(309, ObModIds::OB_INNER_LOB_HASH_SET))) {
|
||||
if (OB_FAIL(inner_lob_map.create(310, ObModIds::OB_INNER_LOB_HASH_SET))) {
|
||||
SERVER_LOG(WARN, "fail to create inner lob map", K(ret));
|
||||
} else {
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < ARRAYSIZEOF(lob_aux_table_mappings); ++i) {
|
||||
|
@ -336,6 +336,7 @@ const uint64_t OB_ALL_SERVICE_TID = 516; // "__all_service"
|
||||
const uint64_t OB_ALL_STORAGE_IO_USAGE_TID = 517; // "__all_storage_io_usage"
|
||||
const uint64_t OB_ALL_MVIEW_DEP_TID = 518; // "__all_mview_dep"
|
||||
const uint64_t OB_ALL_SCHEDULER_JOB_RUN_DETAIL_V2_TID = 519; // "__all_scheduler_job_run_detail_v2"
|
||||
const uint64_t OB_ALL_SPM_EVO_RESULT_TID = 520; // "__all_spm_evo_result"
|
||||
const uint64_t OB_ALL_NCOMP_DLL_V2_TID = 528; // "__all_ncomp_dll_v2"
|
||||
const uint64_t OB_TENANT_VIRTUAL_ALL_TABLE_TID = 10001; // "__tenant_virtual_all_table"
|
||||
const uint64_t OB_TENANT_VIRTUAL_TABLE_COLUMN_TID = 10002; // "__tenant_virtual_table_column"
|
||||
@ -808,6 +809,7 @@ const uint64_t OB_ALL_VIRTUAL_SPATIAL_REFERENCE_SYSTEMS_TID = 12490; // "__all_v
|
||||
const uint64_t OB_ALL_VIRTUAL_LOG_TRANSPORT_DEST_STAT_TID = 12491; // "__all_virtual_log_transport_dest_stat"
|
||||
const uint64_t OB_ALL_VIRTUAL_SS_LOCAL_CACHE_INFO_TID = 12492; // "__all_virtual_ss_local_cache_info"
|
||||
const uint64_t OB_ALL_VIRTUAL_KV_GROUP_COMMIT_STATUS_TID = 12493; // "__all_virtual_kv_group_commit_status"
|
||||
const uint64_t OB_ALL_VIRTUAL_SPM_EVO_RESULT_TID = 12495; // "__all_virtual_spm_evo_result"
|
||||
const uint64_t OB_ALL_VIRTUAL_VECTOR_INDEX_INFO_TID = 12496; // "__all_virtual_vector_index_info"
|
||||
const uint64_t OB_ALL_VIRTUAL_KV_CLIENT_INFO_TID = 12500; // "__all_virtual_kv_client_info"
|
||||
const uint64_t OB_ALL_VIRTUAL_FUNCTION_IO_STAT_TID = 12504; // "__all_virtual_function_io_stat"
|
||||
@ -1095,6 +1097,7 @@ const uint64_t OB_ALL_VIRTUAL_SCHEDULER_JOB_RUN_DETAIL_V2_REAL_AGENT_ORA_TID = 1
|
||||
const uint64_t OB_ALL_VIRTUAL_SPATIAL_REFERENCE_SYSTEMS_REAL_AGENT_ORA_TID = 15459; // "ALL_VIRTUAL_SPATIAL_REFERENCE_SYSTEMS_REAL_AGENT_ORA"
|
||||
const uint64_t OB_ALL_VIRTUAL_LOG_TRANSPORT_DEST_STAT_ORA_TID = 15461; // "ALL_VIRTUAL_LOG_TRANSPORT_DEST_STAT_ORA"
|
||||
const uint64_t OB_ALL_VIRTUAL_SS_LOCAL_CACHE_INFO_ORA_TID = 15462; // "ALL_VIRTUAL_SS_LOCAL_CACHE_INFO_ORA"
|
||||
const uint64_t OB_ALL_VIRTUAL_SPM_EVO_RESULT_ORA_TID = 15466; // "ALL_VIRTUAL_SPM_EVO_RESULT_ORA"
|
||||
const uint64_t OB_ALL_VIRTUAL_VECTOR_INDEX_INFO_ORA_TID = 15467; // "ALL_VIRTUAL_VECTOR_INDEX_INFO_ORA"
|
||||
const uint64_t OB_ALL_VIRTUAL_FUNCTION_IO_STAT_ORA_TID = 15484; // "ALL_VIRTUAL_FUNCTION_IO_STAT_ORA"
|
||||
const uint64_t OB_ALL_VIRTUAL_TEMP_FILE_ORA_TID = 15485; // "ALL_VIRTUAL_TEMP_FILE_ORA"
|
||||
@ -1588,6 +1591,8 @@ const uint64_t OB_INNODB_SYS_FOREIGN_TID = 21604; // "INNODB_SYS_FOREIGN"
|
||||
const uint64_t OB_INNODB_SYS_FOREIGN_COLS_TID = 21605; // "INNODB_SYS_FOREIGN_COLS"
|
||||
const uint64_t OB_GV_OB_KV_CLIENT_INFO_TID = 21607; // "GV$OB_KV_CLIENT_INFO"
|
||||
const uint64_t OB_V_OB_KV_CLIENT_INFO_TID = 21608; // "V$OB_KV_CLIENT_INFO"
|
||||
const uint64_t OB_DBA_OB_SPM_EVO_RESULT_TID = 21616; // "DBA_OB_SPM_EVO_RESULT"
|
||||
const uint64_t OB_CDB_OB_SPM_EVO_RESULT_TID = 21617; // "CDB_OB_SPM_EVO_RESULT"
|
||||
const uint64_t OB_GV_OB_FUNCTION_IO_STAT_TID = 21620; // "GV$OB_FUNCTION_IO_STAT"
|
||||
const uint64_t OB_V_OB_FUNCTION_IO_STAT_TID = 21621; // "V$OB_FUNCTION_IO_STAT"
|
||||
const uint64_t OB_DBA_OB_TEMP_FILES_TID = 21622; // "DBA_OB_TEMP_FILES"
|
||||
@ -2072,6 +2077,7 @@ const uint64_t OB_GV_OB_LOG_TRANSPORT_DEST_STAT_ORA_TID = 28238; // "GV$OB_LOG_T
|
||||
const uint64_t OB_V_OB_LOG_TRANSPORT_DEST_STAT_ORA_TID = 28239; // "V$OB_LOG_TRANSPORT_DEST_STAT_ORA"
|
||||
const uint64_t OB_GV_OB_SS_LOCAL_CACHE_ORA_TID = 28240; // "GV$OB_SS_LOCAL_CACHE_ORA"
|
||||
const uint64_t OB_V_OB_SS_LOCAL_CACHE_ORA_TID = 28241; // "V$OB_SS_LOCAL_CACHE_ORA"
|
||||
const uint64_t OB_DBA_OB_SPM_EVO_RESULT_ORA_TID = 28261; // "DBA_OB_SPM_EVO_RESULT_ORA"
|
||||
const uint64_t OB_GV_OB_FUNCTION_IO_STAT_ORA_TID = 28262; // "GV$OB_FUNCTION_IO_STAT_ORA"
|
||||
const uint64_t OB_V_OB_FUNCTION_IO_STAT_ORA_TID = 28263; // "V$OB_FUNCTION_IO_STAT_ORA"
|
||||
const uint64_t OB_DBA_OB_TEMP_FILES_ORA_TID = 28264; // "DBA_OB_TEMP_FILES_ORA"
|
||||
@ -2383,6 +2389,7 @@ const uint64_t OB_ALL_SERVICE_AUX_LOB_META_TID = 50516; // "__all_service_aux_lo
|
||||
const uint64_t OB_ALL_STORAGE_IO_USAGE_AUX_LOB_META_TID = 50517; // "__all_storage_io_usage_aux_lob_meta"
|
||||
const uint64_t OB_ALL_MVIEW_DEP_AUX_LOB_META_TID = 50518; // "__all_mview_dep_aux_lob_meta"
|
||||
const uint64_t OB_ALL_SCHEDULER_JOB_RUN_DETAIL_V2_AUX_LOB_META_TID = 50519; // "__all_scheduler_job_run_detail_v2_aux_lob_meta"
|
||||
const uint64_t OB_ALL_SPM_EVO_RESULT_AUX_LOB_META_TID = 50520; // "__all_spm_evo_result_aux_lob_meta"
|
||||
const uint64_t OB_ALL_NCOMP_DLL_V2_AUX_LOB_META_TID = 50528; // "__all_ncomp_dll_v2_aux_lob_meta"
|
||||
const uint64_t OB_ALL_TABLE_AUX_LOB_PIECE_TID = 60003; // "__all_table_aux_lob_piece"
|
||||
const uint64_t OB_ALL_COLUMN_AUX_LOB_PIECE_TID = 60004; // "__all_column_aux_lob_piece"
|
||||
@ -2692,6 +2699,7 @@ const uint64_t OB_ALL_SERVICE_AUX_LOB_PIECE_TID = 60516; // "__all_service_aux_l
|
||||
const uint64_t OB_ALL_STORAGE_IO_USAGE_AUX_LOB_PIECE_TID = 60517; // "__all_storage_io_usage_aux_lob_piece"
|
||||
const uint64_t OB_ALL_MVIEW_DEP_AUX_LOB_PIECE_TID = 60518; // "__all_mview_dep_aux_lob_piece"
|
||||
const uint64_t OB_ALL_SCHEDULER_JOB_RUN_DETAIL_V2_AUX_LOB_PIECE_TID = 60519; // "__all_scheduler_job_run_detail_v2_aux_lob_piece"
|
||||
const uint64_t OB_ALL_SPM_EVO_RESULT_AUX_LOB_PIECE_TID = 60520; // "__all_spm_evo_result_aux_lob_piece"
|
||||
const uint64_t OB_ALL_NCOMP_DLL_V2_AUX_LOB_PIECE_TID = 60528; // "__all_ncomp_dll_v2_aux_lob_piece"
|
||||
const uint64_t OB_ALL_VIRTUAL_PLAN_CACHE_STAT_ALL_VIRTUAL_PLAN_CACHE_STAT_I1_TID = 14999; // "__all_virtual_plan_cache_stat"
|
||||
const uint64_t OB_ALL_VIRTUAL_SESSION_EVENT_ALL_VIRTUAL_SESSION_EVENT_I1_TID = 14998; // "__all_virtual_session_event"
|
||||
@ -3209,6 +3217,7 @@ const char *const OB_ALL_SERVICE_TNAME = "__all_service";
|
||||
const char *const OB_ALL_STORAGE_IO_USAGE_TNAME = "__all_storage_io_usage";
|
||||
const char *const OB_ALL_MVIEW_DEP_TNAME = "__all_mview_dep";
|
||||
const char *const OB_ALL_SCHEDULER_JOB_RUN_DETAIL_V2_TNAME = "__all_scheduler_job_run_detail_v2";
|
||||
const char *const OB_ALL_SPM_EVO_RESULT_TNAME = "__all_spm_evo_result";
|
||||
const char *const OB_ALL_NCOMP_DLL_V2_TNAME = "__all_ncomp_dll_v2";
|
||||
const char *const OB_TENANT_VIRTUAL_ALL_TABLE_TNAME = "__tenant_virtual_all_table";
|
||||
const char *const OB_TENANT_VIRTUAL_TABLE_COLUMN_TNAME = "__tenant_virtual_table_column";
|
||||
@ -3681,6 +3690,7 @@ const char *const OB_ALL_VIRTUAL_SPATIAL_REFERENCE_SYSTEMS_TNAME = "__all_virtua
|
||||
const char *const OB_ALL_VIRTUAL_LOG_TRANSPORT_DEST_STAT_TNAME = "__all_virtual_log_transport_dest_stat";
|
||||
const char *const OB_ALL_VIRTUAL_SS_LOCAL_CACHE_INFO_TNAME = "__all_virtual_ss_local_cache_info";
|
||||
const char *const OB_ALL_VIRTUAL_KV_GROUP_COMMIT_STATUS_TNAME = "__all_virtual_kv_group_commit_status";
|
||||
const char *const OB_ALL_VIRTUAL_SPM_EVO_RESULT_TNAME = "__all_virtual_spm_evo_result";
|
||||
const char *const OB_ALL_VIRTUAL_VECTOR_INDEX_INFO_TNAME = "__all_virtual_vector_index_info";
|
||||
const char *const OB_ALL_VIRTUAL_KV_CLIENT_INFO_TNAME = "__all_virtual_kv_client_info";
|
||||
const char *const OB_ALL_VIRTUAL_FUNCTION_IO_STAT_TNAME = "__all_virtual_function_io_stat";
|
||||
@ -3968,6 +3978,7 @@ const char *const OB_ALL_VIRTUAL_SCHEDULER_JOB_RUN_DETAIL_V2_REAL_AGENT_ORA_TNAM
|
||||
const char *const OB_ALL_VIRTUAL_SPATIAL_REFERENCE_SYSTEMS_REAL_AGENT_ORA_TNAME = "ALL_VIRTUAL_SPATIAL_REFERENCE_SYSTEMS_REAL_AGENT";
|
||||
const char *const OB_ALL_VIRTUAL_LOG_TRANSPORT_DEST_STAT_ORA_TNAME = "ALL_VIRTUAL_LOG_TRANSPORT_DEST_STAT";
|
||||
const char *const OB_ALL_VIRTUAL_SS_LOCAL_CACHE_INFO_ORA_TNAME = "ALL_VIRTUAL_SS_LOCAL_CACHE_INFO";
|
||||
const char *const OB_ALL_VIRTUAL_SPM_EVO_RESULT_ORA_TNAME = "ALL_VIRTUAL_SPM_EVO_RESULT";
|
||||
const char *const OB_ALL_VIRTUAL_VECTOR_INDEX_INFO_ORA_TNAME = "ALL_VIRTUAL_VECTOR_INDEX_INFO";
|
||||
const char *const OB_ALL_VIRTUAL_FUNCTION_IO_STAT_ORA_TNAME = "ALL_VIRTUAL_FUNCTION_IO_STAT";
|
||||
const char *const OB_ALL_VIRTUAL_TEMP_FILE_ORA_TNAME = "ALL_VIRTUAL_TEMP_FILE";
|
||||
@ -4461,6 +4472,8 @@ const char *const OB_INNODB_SYS_FOREIGN_TNAME = "INNODB_SYS_FOREIGN";
|
||||
const char *const OB_INNODB_SYS_FOREIGN_COLS_TNAME = "INNODB_SYS_FOREIGN_COLS";
|
||||
const char *const OB_GV_OB_KV_CLIENT_INFO_TNAME = "GV$OB_KV_CLIENT_INFO";
|
||||
const char *const OB_V_OB_KV_CLIENT_INFO_TNAME = "V$OB_KV_CLIENT_INFO";
|
||||
const char *const OB_DBA_OB_SPM_EVO_RESULT_TNAME = "DBA_OB_SPM_EVO_RESULT";
|
||||
const char *const OB_CDB_OB_SPM_EVO_RESULT_TNAME = "CDB_OB_SPM_EVO_RESULT";
|
||||
const char *const OB_GV_OB_FUNCTION_IO_STAT_TNAME = "GV$OB_FUNCTION_IO_STAT";
|
||||
const char *const OB_V_OB_FUNCTION_IO_STAT_TNAME = "V$OB_FUNCTION_IO_STAT";
|
||||
const char *const OB_DBA_OB_TEMP_FILES_TNAME = "DBA_OB_TEMP_FILES";
|
||||
@ -4945,6 +4958,7 @@ const char *const OB_GV_OB_LOG_TRANSPORT_DEST_STAT_ORA_TNAME = "GV$OB_LOG_TRANSP
|
||||
const char *const OB_V_OB_LOG_TRANSPORT_DEST_STAT_ORA_TNAME = "V$OB_LOG_TRANSPORT_DEST_STAT";
|
||||
const char *const OB_GV_OB_SS_LOCAL_CACHE_ORA_TNAME = "GV$OB_SS_LOCAL_CACHE";
|
||||
const char *const OB_V_OB_SS_LOCAL_CACHE_ORA_TNAME = "V$OB_SS_LOCAL_CACHE";
|
||||
const char *const OB_DBA_OB_SPM_EVO_RESULT_ORA_TNAME = "DBA_OB_SPM_EVO_RESULT";
|
||||
const char *const OB_GV_OB_FUNCTION_IO_STAT_ORA_TNAME = "GV$OB_FUNCTION_IO_STAT";
|
||||
const char *const OB_V_OB_FUNCTION_IO_STAT_ORA_TNAME = "V$OB_FUNCTION_IO_STAT";
|
||||
const char *const OB_DBA_OB_TEMP_FILES_ORA_TNAME = "DBA_OB_TEMP_FILES";
|
||||
@ -5256,6 +5270,7 @@ const char *const OB_ALL_SERVICE_AUX_LOB_META_TNAME = "__all_service_aux_lob_met
|
||||
const char *const OB_ALL_STORAGE_IO_USAGE_AUX_LOB_META_TNAME = "__all_storage_io_usage_aux_lob_meta";
|
||||
const char *const OB_ALL_MVIEW_DEP_AUX_LOB_META_TNAME = "__all_mview_dep_aux_lob_meta";
|
||||
const char *const OB_ALL_SCHEDULER_JOB_RUN_DETAIL_V2_AUX_LOB_META_TNAME = "__all_scheduler_job_run_detail_v2_aux_lob_meta";
|
||||
const char *const OB_ALL_SPM_EVO_RESULT_AUX_LOB_META_TNAME = "__all_spm_evo_result_aux_lob_meta";
|
||||
const char *const OB_ALL_NCOMP_DLL_V2_AUX_LOB_META_TNAME = "__all_ncomp_dll_v2_aux_lob_meta";
|
||||
const char *const OB_ALL_TABLE_AUX_LOB_PIECE_TNAME = "__all_table_aux_lob_piece";
|
||||
const char *const OB_ALL_COLUMN_AUX_LOB_PIECE_TNAME = "__all_column_aux_lob_piece";
|
||||
@ -5565,6 +5580,7 @@ const char *const OB_ALL_SERVICE_AUX_LOB_PIECE_TNAME = "__all_service_aux_lob_pi
|
||||
const char *const OB_ALL_STORAGE_IO_USAGE_AUX_LOB_PIECE_TNAME = "__all_storage_io_usage_aux_lob_piece";
|
||||
const char *const OB_ALL_MVIEW_DEP_AUX_LOB_PIECE_TNAME = "__all_mview_dep_aux_lob_piece";
|
||||
const char *const OB_ALL_SCHEDULER_JOB_RUN_DETAIL_V2_AUX_LOB_PIECE_TNAME = "__all_scheduler_job_run_detail_v2_aux_lob_piece";
|
||||
const char *const OB_ALL_SPM_EVO_RESULT_AUX_LOB_PIECE_TNAME = "__all_spm_evo_result_aux_lob_piece";
|
||||
const char *const OB_ALL_NCOMP_DLL_V2_AUX_LOB_PIECE_TNAME = "__all_ncomp_dll_v2_aux_lob_piece";
|
||||
const char *const OB_ALL_VIRTUAL_PLAN_CACHE_STAT_ALL_VIRTUAL_PLAN_CACHE_STAT_I1_TNAME = "__idx_11003_all_virtual_plan_cache_stat_i1";
|
||||
const char *const OB_ALL_VIRTUAL_SESSION_EVENT_ALL_VIRTUAL_SESSION_EVENT_I1_TNAME = "__idx_11013_all_virtual_session_event_i1";
|
||||
|
@ -7513,7 +7513,36 @@ def_table_schema(
|
||||
],
|
||||
)
|
||||
|
||||
# 520 : __all_spm_evo_result
|
||||
def_table_schema(
|
||||
owner = 'yibo.tyf',
|
||||
table_id = '520',
|
||||
table_name = '__all_spm_evo_result',
|
||||
table_type = 'SYSTEM_TABLE',
|
||||
gm_columns = [],
|
||||
rowkey_columns = [
|
||||
('tenant_id', 'int'),
|
||||
('record_time', 'timestamp'),
|
||||
('svr_ip', 'varchar:MAX_IP_ADDR_LENGTH'),
|
||||
('svr_port', 'int'),
|
||||
],
|
||||
in_tenant_space=True,
|
||||
is_cluster_private=True,
|
||||
meta_record_in_sys = False,
|
||||
normal_columns = [
|
||||
('database_id', 'int'),
|
||||
('sql_id', 'varchar:OB_MAX_SQL_ID_LENGTH'),
|
||||
('type', 'int'),
|
||||
('start_time', 'timestamp', 'true'),
|
||||
('end_time', 'timestamp', 'true'),
|
||||
('status', 'varchar:7', 'true'),
|
||||
('new_plan_better', 'bool', 'true'),
|
||||
('evo_plan_exec_count', 'int', 'true'),
|
||||
('evo_plan_cpu_time', 'int', 'true'),
|
||||
('baseline_exec_count', 'int', 'true'),
|
||||
('baseline_cpu_time', 'int', 'true'),
|
||||
],
|
||||
)
|
||||
|
||||
# 521 : __all_detect_lock_info_v2
|
||||
# 522 : __all_pkg_type
|
||||
# 523 : __all_pkg_type_attr
|
||||
@ -15091,7 +15120,12 @@ def_table_schema(
|
||||
vtable_route_policy = 'distributed',
|
||||
)
|
||||
# 12494: __all_virtual_session_sys_variable
|
||||
# 12495: __all_virtual_spm_evo_result
|
||||
def_table_schema(**gen_iterate_private_virtual_table_def(
|
||||
table_id = '12495',
|
||||
table_name = '__all_virtual_spm_evo_result',
|
||||
in_tenant_space = True,
|
||||
keywords = all_def_keywords['__all_spm_evo_result']))
|
||||
|
||||
def_table_schema(
|
||||
owner = 'huhaosheng.hhs',
|
||||
table_name = '__all_virtual_vector_index_info',
|
||||
@ -15733,7 +15767,7 @@ def_table_schema(**no_direct_access(gen_oracle_mapping_virtual_table_def('15462'
|
||||
# 15464: __all_virtual_kv_group_commit_status
|
||||
|
||||
# 15465: __all_virtual_session_sys_variable
|
||||
# 15466: __all_spm_evo_result
|
||||
def_table_schema(**gen_oracle_mapping_virtual_table_def('15466', all_def_keywords['__all_virtual_spm_evo_result']))
|
||||
# 15467: __all_virtual_vector_index_info
|
||||
|
||||
# 15468: __all_pkg_type
|
||||
@ -25811,7 +25845,7 @@ def_table_schema(
|
||||
CAST(NULL AS NUMBER) AS IM_BLOCK_COUNT,
|
||||
CAST(NULL AS DATETIME) AS IM_STAT_UPDATE_TIME,
|
||||
CAST(NULL AS NUMBER) AS SCAN_RATE,
|
||||
CAST(STAT.SPARE1 AS NUMBER) AS SAMPLE_SIZE,
|
||||
CAST(STAT.SPARE1 AS DECIMAL(20, 0)) AS SAMPLE_SIZE,
|
||||
CAST(STAT.LAST_ANALYZED AS DATETIME(6)) AS LAST_ANALYZED,
|
||||
CAST((CASE STAT.GLOBAL_STATS WHEN 0 THEN 'NO' WHEN 1 THEN 'YES' ELSE NULL END) AS CHAR(3)) AS GLOBAL_STATS,
|
||||
CAST((CASE STAT.USER_STATS WHEN 0 THEN 'NO' WHEN 1 THEN 'YES' ELSE NULL END) AS CHAR(3)) AS USER_STATS,
|
||||
@ -38156,8 +38190,78 @@ def_table_schema(
|
||||
# 21613: CDB_WR_SQL_PLAN
|
||||
# 21614: DBA_WR_RES_MGR_SYSSTAT
|
||||
# 21615: CDB_WR_RES_MGR_SYSSTAT
|
||||
# 21616: DBA_OB_SPM_EVO_RESULT
|
||||
# 21617: CDB_OB_SPM_EVO_RESULT
|
||||
|
||||
def_table_schema(
|
||||
owner = 'yibo.tyf',
|
||||
table_name = 'DBA_OB_SPM_EVO_RESULT',
|
||||
table_id = '21616',
|
||||
table_type = 'SYSTEM_VIEW',
|
||||
rowkey_columns = [],
|
||||
normal_columns = [],
|
||||
gm_columns = [],
|
||||
in_tenant_space = True,
|
||||
view_definition = """
|
||||
SELECT D.DATABASE_NAME AS OWNER,
|
||||
RECORD_TIME,
|
||||
SVR_IP,
|
||||
SVR_PORT,
|
||||
SQL_ID,
|
||||
CAST(CASE WHEN TYPE = 0 THEN 'OnlineEvolve'
|
||||
WHEN TYPE = 1 THEN 'FirstBaseline'
|
||||
WHEN TYPE = 2 THEN 'UnReproducible'
|
||||
WHEN TYPE = 3 THEN 'BaselineFirst'
|
||||
ELSE NULL END AS CHAR(32)) AS TYPE,
|
||||
START_TIME,
|
||||
END_TIME,
|
||||
STATUS,
|
||||
NEW_PLAN_BETTER,
|
||||
EVO_PLAN_EXEC_COUNT,
|
||||
EVO_PLAN_CPU_TIME,
|
||||
BASELINE_EXEC_COUNT,
|
||||
BASELINE_CPU_TIME
|
||||
FROM OCEANBASE.__ALL_VIRTUAL_SPM_EVO_RESULT R,
|
||||
OCEANBASE.__ALL_DATABASE D
|
||||
WHERE R.TENANT_ID = EFFECTIVE_TENANT_ID()
|
||||
AND D.TENANT_ID = 0
|
||||
AND R.DATABASE_ID = D.DATABASE_ID
|
||||
""".replace("\n", " ")
|
||||
)
|
||||
|
||||
def_table_schema(
|
||||
owner = 'yibo.tyf',
|
||||
table_name = 'CDB_OB_SPM_EVO_RESULT',
|
||||
table_id = '21617',
|
||||
table_type = 'SYSTEM_VIEW',
|
||||
rowkey_columns = [],
|
||||
normal_columns = [],
|
||||
gm_columns = [],
|
||||
view_definition = """
|
||||
SELECT R.TENANT_ID,
|
||||
D.DATABASE_NAME AS OWNER,
|
||||
RECORD_TIME,
|
||||
SVR_IP,
|
||||
SVR_PORT,
|
||||
SQL_ID,
|
||||
CAST(CASE WHEN TYPE = 0 THEN 'OnlineEvolve'
|
||||
WHEN TYPE = 1 THEN 'FirstBaseline'
|
||||
WHEN TYPE = 2 THEN 'UnReproducible'
|
||||
WHEN TYPE = 3 THEN 'BaselineFirst'
|
||||
ELSE NULL END AS CHAR(32)) AS TYPE,
|
||||
START_TIME,
|
||||
END_TIME,
|
||||
STATUS,
|
||||
NEW_PLAN_BETTER,
|
||||
EVO_PLAN_EXEC_COUNT,
|
||||
EVO_PLAN_CPU_TIME,
|
||||
BASELINE_EXEC_COUNT,
|
||||
BASELINE_CPU_TIME
|
||||
FROM OCEANBASE.__ALL_VIRTUAL_SPM_EVO_RESULT R,
|
||||
OCEANBASE.__ALL_VIRTUAL_DATABASE D
|
||||
WHERE R.TENANT_ID = D.TENANT_ID
|
||||
AND R.DATABASE_ID = D.DATABASE_ID
|
||||
""".replace("\n", " ")
|
||||
)
|
||||
|
||||
# 21618: DBA_OB_KV_REDIS_TABLE
|
||||
# 21619: CDB_OB_KV_REDIS_TABLE
|
||||
|
||||
@ -67081,7 +67185,44 @@ def_table_schema(
|
||||
# 28258: V$OB_RES_MGR_SYSSTAT
|
||||
# 28259: DBA_WR_SQL_PLAN
|
||||
# 28260: DBA_WR_RES_MGR_SYSSTAT
|
||||
# 28261: DBA_OB_SPM_EVO_RESULT
|
||||
|
||||
def_table_schema(
|
||||
owner = 'yibo.tyf',
|
||||
table_name = 'DBA_OB_SPM_EVO_RESULT',
|
||||
name_postfix = '_ORA',
|
||||
database_id = 'OB_ORA_SYS_DATABASE_ID',
|
||||
table_id = '28261',
|
||||
table_type = 'SYSTEM_VIEW',
|
||||
rowkey_columns = [],
|
||||
normal_columns = [],
|
||||
gm_columns = [],
|
||||
in_tenant_space = True,
|
||||
view_definition = """
|
||||
SELECT D.DATABASE_NAME AS OWNER,
|
||||
RECORD_TIME,
|
||||
SVR_IP,
|
||||
SVR_PORT,
|
||||
SQL_ID,
|
||||
CAST(CASE WHEN TYPE = 0 THEN 'OnlineEvolve'
|
||||
WHEN TYPE = 1 THEN 'FirstBaseline'
|
||||
WHEN TYPE = 2 THEN 'UnReproducible'
|
||||
WHEN TYPE = 3 THEN 'BaselineFirst'
|
||||
ELSE NULL END AS VARCHAR(32)) AS TYPE,
|
||||
START_TIME,
|
||||
END_TIME,
|
||||
STATUS,
|
||||
NEW_PLAN_BETTER,
|
||||
EVO_PLAN_EXEC_COUNT,
|
||||
EVO_PLAN_CPU_TIME,
|
||||
BASELINE_EXEC_COUNT,
|
||||
BASELINE_CPU_TIME
|
||||
FROM SYS.ALL_VIRTUAL_SPM_EVO_RESULT R,
|
||||
SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT D
|
||||
WHERE R.TENANT_ID = EFFECTIVE_TENANT_ID()
|
||||
AND D.TENANT_ID = EFFECTIVE_TENANT_ID()
|
||||
AND R.DATABASE_ID = D.DATABASE_ID
|
||||
""".replace("\n", " ")
|
||||
)
|
||||
|
||||
def_table_schema(
|
||||
owner = 'zz412656',
|
||||
|
@ -525,6 +525,7 @@ case OB_ALL_VIRTUAL_RESTORE_JOB_TID:
|
||||
case OB_ALL_VIRTUAL_RESTORE_JOB_HISTORY_TID:
|
||||
case OB_ALL_VIRTUAL_RESTORE_PROGRESS_TID:
|
||||
case OB_ALL_VIRTUAL_SERVICE_TID:
|
||||
case OB_ALL_VIRTUAL_SPM_EVO_RESULT_TID:
|
||||
case OB_ALL_VIRTUAL_STORAGE_IO_USAGE_TID:
|
||||
case OB_ALL_VIRTUAL_TABLE_OPT_STAT_GATHER_HISTORY_TID:
|
||||
case OB_ALL_VIRTUAL_TABLET_CHECKSUM_ERROR_INFO_TID:
|
||||
@ -1519,6 +1520,22 @@ case OB_ALL_VIRTUAL_ZONE_MERGE_INFO_TID:
|
||||
END_CREATE_VT_ITER_SWITCH_LAMBDA
|
||||
|
||||
BEGIN_CREATE_VT_ITER_SWITCH_LAMBDA
|
||||
case OB_ALL_VIRTUAL_SPM_EVO_RESULT_TID: {
|
||||
ObIteratePrivateVirtualTable *iter = NULL;
|
||||
const bool meta_record_in_sys = false;
|
||||
if (OB_FAIL(NEW_VIRTUAL_TABLE(ObIteratePrivateVirtualTable, iter))) {
|
||||
SERVER_LOG(WARN, "create iterate private virtual table iterator failed", KR(ret));
|
||||
} else if (OB_FAIL(iter->init(OB_ALL_SPM_EVO_RESULT_TID, meta_record_in_sys, index_schema, params))) {
|
||||
SERVER_LOG(WARN, "iterate private virtual table iter init failed", KR(ret));
|
||||
iter->~ObIteratePrivateVirtualTable();
|
||||
allocator.free(iter);
|
||||
iter = NULL;
|
||||
} else {
|
||||
vt_iter = iter;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case OB_ALL_VIRTUAL_STORAGE_IO_USAGE_TID: {
|
||||
ObIteratePrivateVirtualTable *iter = NULL;
|
||||
const bool meta_record_in_sys = false;
|
||||
@ -1822,7 +1839,9 @@ case OB_ALL_VIRTUAL_ZONE_MERGE_INFO_TID:
|
||||
}
|
||||
break;
|
||||
}
|
||||
END_CREATE_VT_ITER_SWITCH_LAMBDA
|
||||
|
||||
BEGIN_CREATE_VT_ITER_SWITCH_LAMBDA
|
||||
case OB_ALL_VIRTUAL_WR_SYSSTAT_TID: {
|
||||
ObIteratePrivateVirtualTable *iter = NULL;
|
||||
const bool meta_record_in_sys = false;
|
||||
@ -1838,9 +1857,7 @@ case OB_ALL_VIRTUAL_ZONE_MERGE_INFO_TID:
|
||||
}
|
||||
break;
|
||||
}
|
||||
END_CREATE_VT_ITER_SWITCH_LAMBDA
|
||||
|
||||
BEGIN_CREATE_VT_ITER_SWITCH_LAMBDA
|
||||
case OB_ALL_VIRTUAL_ZONE_MERGE_INFO_TID: {
|
||||
ObIteratePrivateVirtualTable *iter = NULL;
|
||||
const bool meta_record_in_sys = false;
|
||||
@ -5028,6 +5045,9 @@ case OB_ALL_SERVICE_AUX_LOB_PIECE_TID:
|
||||
case OB_ALL_SERVICE_EPOCH_TID:
|
||||
case OB_ALL_SERVICE_EPOCH_AUX_LOB_META_TID:
|
||||
case OB_ALL_SERVICE_EPOCH_AUX_LOB_PIECE_TID:
|
||||
case OB_ALL_SPM_EVO_RESULT_TID:
|
||||
case OB_ALL_SPM_EVO_RESULT_AUX_LOB_META_TID:
|
||||
case OB_ALL_SPM_EVO_RESULT_AUX_LOB_PIECE_TID:
|
||||
case OB_ALL_STORAGE_IO_USAGE_TID:
|
||||
case OB_ALL_STORAGE_IO_USAGE_AUX_LOB_META_TID:
|
||||
case OB_ALL_STORAGE_IO_USAGE_AUX_LOB_PIECE_TID:
|
||||
|
@ -365,6 +365,7 @@
|
||||
# 517: __all_storage_io_usage
|
||||
# 518: __all_mview_dep
|
||||
# 519: __all_scheduler_job_run_detail_v2
|
||||
# 520: __all_spm_evo_result
|
||||
# 528: __all_ncomp_dll_v2
|
||||
# 10001: __tenant_virtual_all_table
|
||||
# 10002: __tenant_virtual_table_column
|
||||
@ -1160,6 +1161,8 @@
|
||||
# 12491: __all_virtual_log_transport_dest_stat
|
||||
# 12492: __all_virtual_ss_local_cache_info
|
||||
# 12493: __all_virtual_kv_group_commit_status
|
||||
# 12495: __all_virtual_spm_evo_result
|
||||
# 12495: __all_spm_evo_result # BASE_TABLE_NAME
|
||||
# 12496: __all_virtual_vector_index_info
|
||||
# 12500: __all_virtual_kv_client_info
|
||||
# 12504: __all_virtual_function_io_stat
|
||||
@ -1790,6 +1793,9 @@
|
||||
# 15461: __all_virtual_log_transport_dest_stat # BASE_TABLE_NAME
|
||||
# 15462: ALL_VIRTUAL_SS_LOCAL_CACHE_INFO
|
||||
# 15462: __all_virtual_ss_local_cache_info # BASE_TABLE_NAME
|
||||
# 15466: ALL_VIRTUAL_SPM_EVO_RESULT
|
||||
# 15466: __all_spm_evo_result # BASE_TABLE_NAME
|
||||
# 15466: __all_virtual_spm_evo_result # BASE_TABLE_NAME1
|
||||
# 15467: ALL_VIRTUAL_VECTOR_INDEX_INFO
|
||||
# 15467: __all_virtual_vector_index_info # BASE_TABLE_NAME
|
||||
# 15484: ALL_VIRTUAL_FUNCTION_IO_STAT
|
||||
@ -2288,6 +2294,8 @@
|
||||
# 21605: INNODB_SYS_FOREIGN_COLS
|
||||
# 21607: GV$OB_KV_CLIENT_INFO
|
||||
# 21608: V$OB_KV_CLIENT_INFO
|
||||
# 21616: DBA_OB_SPM_EVO_RESULT
|
||||
# 21617: CDB_OB_SPM_EVO_RESULT
|
||||
# 21620: GV$OB_FUNCTION_IO_STAT
|
||||
# 21621: V$OB_FUNCTION_IO_STAT
|
||||
# 21622: DBA_OB_TEMP_FILES
|
||||
@ -2772,6 +2780,7 @@
|
||||
# 28239: V$OB_LOG_TRANSPORT_DEST_STAT
|
||||
# 28240: GV$OB_SS_LOCAL_CACHE
|
||||
# 28241: V$OB_SS_LOCAL_CACHE
|
||||
# 28261: DBA_OB_SPM_EVO_RESULT
|
||||
# 28262: GV$OB_FUNCTION_IO_STAT
|
||||
# 28263: V$OB_FUNCTION_IO_STAT
|
||||
# 28264: DBA_OB_TEMP_FILES
|
||||
|
@ -1630,6 +1630,11 @@ int ObUpgradeFor4330Processor::post_upgrade_for_optimizer_stats()
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* =========== 4250 upgrade processor end ============= */
|
||||
|
||||
/* =========== 4330 upgrade processor end ============= */
|
||||
|
||||
/* =========== 4340 upgrade processor start ============= */
|
||||
int ObUpgradeFor4340Processor::post_upgrade()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -1679,10 +1684,92 @@ int ObUpgradeFor4340Processor::post_upgrade_for_persitent_routine()
|
||||
|
||||
return ret;
|
||||
}
|
||||
/* =========== 4340 upgrade processor end ============= */
|
||||
|
||||
/* =========== 4250 upgrade processor end ============= */
|
||||
/* =========== 4350 upgrade processor start ============= */
|
||||
int ObUpgradeFor4350Processor::post_upgrade()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_FAIL(check_inner_stat())) {
|
||||
LOG_WARN("fail to check inner stat", KR(ret));
|
||||
} else if (OB_FAIL(add_spm_stats_scheduler_job())) {
|
||||
LOG_WARN("fail to create standby replication role in oracle", KR(ret));
|
||||
} else if (OB_FAIL(post_upgrade_for_optimizer_stats())) {
|
||||
LOG_WARN("fail to post upgrade for optimizer stats", KR(ret));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* =========== 4330 upgrade processor end ============= */
|
||||
int ObUpgradeFor4350Processor::add_spm_stats_scheduler_job()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
lib::Worker::CompatMode compat_mode = lib::Worker::CompatMode::INVALID;
|
||||
bool is_primary_tenant = false;
|
||||
bool job_exists = false;
|
||||
ObSchemaGetterGuard schema_guard;
|
||||
const ObSysVariableSchema *var_schema = NULL;
|
||||
ObSqlString insert_sql;
|
||||
int64_t affected_rows = 0;
|
||||
if (OB_ISNULL(sql_proxy_) || OB_ISNULL(schema_service_) || !is_valid_tenant_id(tenant_id_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected error", KR(ret), KP_(sql_proxy), KP_(schema_service), K_(tenant_id));
|
||||
} else if (OB_FAIL(ObAllTenantInfoProxy::is_primary_tenant(sql_proxy_, tenant_id_, is_primary_tenant))) {
|
||||
LOG_WARN("check is standby tenant failed", K(ret), K(tenant_id_));
|
||||
} else if (!is_primary_tenant) {
|
||||
LOG_INFO("tenant isn't primary tenant", K(tenant_id_));
|
||||
} else if (OB_FAIL(ObDbmsStatsMaintenanceWindow::check_job_exists(sql_proxy_,
|
||||
tenant_id_,
|
||||
"SPM_STATS_MANAGER",
|
||||
job_exists))) {
|
||||
LOG_WARN("failed to check job exists");
|
||||
} else if (job_exists) {
|
||||
LOG_INFO("spm schedular job already exists", K(tenant_id_), "job_name", "SPM_STATS_MANAGER");
|
||||
} else if (OB_FAIL(schema_service_->get_tenant_schema_guard(tenant_id_, schema_guard))) {
|
||||
LOG_WARN("failed to get schema guard", K(ret));
|
||||
} else if (OB_FAIL(schema_guard.get_sys_variable_schema(tenant_id_, var_schema))) {
|
||||
LOG_WARN("fail to get sys variable schema", KR(ret), K_(tenant_id));
|
||||
} else if (OB_FAIL(ObCompatModeGetter::get_tenant_mode(tenant_id_, compat_mode))) {
|
||||
LOG_WARN("failed to get tenant compat mode", KR(ret), K_(tenant_id));
|
||||
} else if (OB_FAIL(ObDbmsStatsMaintenanceWindow::get_spm_stats_upgrade_jobs_sql(sql_proxy_,
|
||||
*var_schema,
|
||||
tenant_id_,
|
||||
lib::Worker::CompatMode::ORACLE == compat_mode,
|
||||
insert_sql))) {
|
||||
LOG_WARN("failed to get spm stats upgrade jobs sql");
|
||||
} else if (OB_FAIL(sql_proxy_->write(tenant_id_, insert_sql.ptr(), affected_rows))) {
|
||||
LOG_WARN("failed to write spm stats job", K(ret), K(tenant_id_), K(affected_rows), K(insert_sql));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObUpgradeFor4350Processor::post_upgrade_for_optimizer_stats()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObSqlString extra_stats_perfs_sql;
|
||||
int64_t affected_rows = 0;
|
||||
bool is_primary_tenant = false;
|
||||
if (sql_proxy_ == NULL) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("sql_proxy is null", K(ret), K(tenant_id_));
|
||||
} else if (OB_FAIL(ObAllTenantInfoProxy::is_primary_tenant(sql_proxy_, tenant_id_, is_primary_tenant))) {
|
||||
LOG_WARN("check is standby tenant failed", K(ret), K(tenant_id_));
|
||||
} else if (!is_primary_tenant) {
|
||||
LOG_INFO("tenant isn't primary standby, no refer to gather stats, skip", K(tenant_id_));
|
||||
} else if (OB_FAIL(ObDbmsStatsPreferences::get_extra_stats_perfs_for_upgrade_425(extra_stats_perfs_sql))) {
|
||||
LOG_WARN("failed to get extra stats perfs for upgrade", K(ret));
|
||||
} else if (OB_FAIL(sql_proxy_->write(tenant_id_, extra_stats_perfs_sql.ptr(), affected_rows))) {
|
||||
LOG_WARN("failed to write", K(ret));
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
LOG_WARN("[UPGRADE] post upgrade for optimizer stats failed", KR(ret), K_(tenant_id));
|
||||
} else {
|
||||
LOG_INFO("[UPGRADE] post upgrade for optimizer stats succeed", K_(tenant_id));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* =========== 4350 upgrade processor end ============= */
|
||||
|
||||
} // end share
|
||||
} // end oceanbase
|
||||
|
@ -286,6 +286,7 @@ private:
|
||||
int post_upgrade_for_external_table_flag();
|
||||
int post_upgrade_for_service_name();
|
||||
int post_upgrade_for_optimizer_stats();
|
||||
int add_spm_stats_scheduler_job();
|
||||
};
|
||||
DEF_SIMPLE_UPGRARD_PROCESSER(4, 3, 3, 1)
|
||||
|
||||
@ -300,7 +301,17 @@ private:
|
||||
int post_upgrade_for_persitent_routine();
|
||||
};
|
||||
|
||||
DEF_SIMPLE_UPGRARD_PROCESSER(4, 3, 5, 0)
|
||||
class ObUpgradeFor4350Processor : public ObBaseUpgradeProcessor
|
||||
{
|
||||
public:
|
||||
ObUpgradeFor4350Processor() : ObBaseUpgradeProcessor() {}
|
||||
virtual ~ObUpgradeFor4350Processor() {}
|
||||
virtual int pre_upgrade() override { return common::OB_SUCCESS; }
|
||||
virtual int post_upgrade() override;
|
||||
private:
|
||||
int add_spm_stats_scheduler_job();
|
||||
int post_upgrade_for_optimizer_stats();
|
||||
};
|
||||
|
||||
/* =========== special upgrade processor end ============= */
|
||||
|
||||
|
@ -1907,6 +1907,9 @@ DEF_BOOL(_xsolapi_generate_with_clause, OB_TENANT_PARAMETER, "True",
|
||||
DEF_BOOL(_optimizer_group_by_placement, OB_TENANT_PARAMETER, "True",
|
||||
"enable group by placement transform rule",
|
||||
ObParameterAttr(Section::TENANT, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE));
|
||||
DEF_INT(_complex_cbqt_table_num, OB_TENANT_PARAMETER, "10", "[0,)",
|
||||
"cost-based transform will be disabled when table count in a single stmt exceeds threshold",
|
||||
ObParameterAttr(Section::TENANT, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE));
|
||||
DEF_TIME(_wait_interval_after_parallel_ddl, OB_TENANT_PARAMETER, "30s", "[0s,)",
|
||||
"time interval for waiting other servers to refresh schema after parallel ddl is done",
|
||||
ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE));
|
||||
@ -2001,7 +2004,7 @@ DEF_CAP(auto_split_tablet_size, OB_TENANT_PARAMETER, "128M", "[128M,)",
|
||||
"Note that the modification of this config will not affect the created auto-partitioned table."
|
||||
"Range: [128M, +∞)",
|
||||
ObParameterAttr(Section::TENANT, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE));
|
||||
DEF_INT(_inlist_rewrite_threshold, OB_TENANT_PARAMETER, "2147483647", "[1, 2147483647]"
|
||||
DEF_INT(_inlist_rewrite_threshold, OB_TENANT_PARAMETER, "1000", "[1, 2147483647]"
|
||||
"specifies transform how much const params in IN list to values table",
|
||||
ObParameterAttr(Section::TENANT, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE));
|
||||
|
||||
|
@ -300,6 +300,10 @@ int ObDbmsStatsExecutor::prepare_gather_stats(ObExecContext &ctx,
|
||||
const_cast<ObTableStatParam&>(param),
|
||||
gather_helper.use_split_part_))) {
|
||||
LOG_WARN("failed to adjsut async gather param", K(ret));
|
||||
} else if (!gather_helper.use_split_part_ && param.is_auto_sample_size_ &&
|
||||
OB_FAIL(adjust_auto_gather_param(partition_id_block_map,
|
||||
param, gather_helper.use_split_part_))) {
|
||||
LOG_WARN("failed to adjust auto gather param", K(ret));
|
||||
} else if (OB_FAIL(check_need_split_gather(param, gather_helper))) {
|
||||
LOG_WARN("failed to check need split gather", K(ret));
|
||||
} else {
|
||||
@ -1904,7 +1908,7 @@ int ObDbmsStatsExecutor::adjsut_async_gather_param(const PartitionIdBlockMap &pa
|
||||
LOG_WARN("get unexpected error", K(ret), K(block_num_stat));
|
||||
} else {
|
||||
int64_t total_row_cnt = block_num_stat->sstable_row_cnt_ + block_num_stat->memtable_row_cnt_;
|
||||
if (total_row_cnt < param.async_full_table_size_) {
|
||||
if (total_row_cnt < param.auto_sample_row_cnt_) {
|
||||
//do nothing
|
||||
} else if (param.part_level_ == share::schema::ObPartitionLevel::PARTITION_LEVEL_ONE ||
|
||||
param.part_level_ == share::schema::ObPartitionLevel::PARTITION_LEVEL_TWO) {
|
||||
@ -1928,7 +1932,7 @@ int ObDbmsStatsExecutor::adjsut_async_gather_param(const PartitionIdBlockMap &pa
|
||||
} else {
|
||||
int64_t row_cnt = block_num_stat->sstable_row_cnt_ + block_num_stat->memtable_row_cnt_;
|
||||
gather_scan_row_cnt += row_cnt;
|
||||
if (row_cnt > param.async_full_table_size_) {
|
||||
if (row_cnt > param.auto_sample_row_cnt_) {
|
||||
need_split_part = true;
|
||||
if (OB_FAIL(add_var_to_array_no_dup(no_derive_part_ids,
|
||||
param.subpart_infos_.at(i).first_part_id_))) {
|
||||
@ -1994,7 +1998,7 @@ int ObDbmsStatsExecutor::adjsut_async_gather_param(const PartitionIdBlockMap &pa
|
||||
} else {
|
||||
int64_t row_cnt = block_num_stat->sstable_row_cnt_ + block_num_stat->memtable_row_cnt_;
|
||||
gather_scan_row_cnt += row_cnt;
|
||||
if (row_cnt > param.async_full_table_size_) {
|
||||
if (row_cnt > param.auto_sample_row_cnt_) {
|
||||
need_split_part = true;
|
||||
can_derive = false;
|
||||
}
|
||||
@ -2038,6 +2042,75 @@ bool ObDbmsStatsExecutor::is_async_gather_partition_id(const int64_t partition_i
|
||||
return is_found;
|
||||
}
|
||||
|
||||
int ObDbmsStatsExecutor::adjust_auto_gather_param(const PartitionIdBlockMap &partition_id_block_map,
|
||||
const ObTableStatParam ¶m,
|
||||
bool &need_split_part)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (param.is_auto_gather_) {
|
||||
LOG_TRACE("begin to adjsut auto gather param", K(param));
|
||||
if (param.part_level_ == share::schema::ObPartitionLevel::PARTITION_LEVEL_ZERO) {
|
||||
//do nohting
|
||||
} else {
|
||||
BlockNumStat *block_num_stat = NULL;
|
||||
int64_t row_cnt = 0;
|
||||
if (OB_FAIL(partition_id_block_map.get_refactored(param.global_part_id_, block_num_stat))) {
|
||||
if (OB_LIKELY(OB_HASH_NOT_EXIST == ret)) {
|
||||
ret = OB_SUCCESS;
|
||||
} else {
|
||||
LOG_WARN("failed to get refactored", K(ret));
|
||||
}
|
||||
} else if (OB_ISNULL(block_num_stat)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected error", K(ret), K(block_num_stat));
|
||||
} else if (OB_FALSE_IT(row_cnt = block_num_stat->sstable_row_cnt_ + block_num_stat->memtable_row_cnt_)) {
|
||||
} else if (row_cnt < param.auto_sample_row_cnt_) {
|
||||
// do nothing
|
||||
} else {
|
||||
for (int64_t i = 0; OB_SUCC(ret) && !need_split_part && i < param.subpart_infos_.count(); ++i) {
|
||||
if (OB_FAIL(partition_id_block_map.get_refactored(param.subpart_infos_.at(i).part_id_, block_num_stat))) {
|
||||
if (OB_LIKELY(OB_HASH_NOT_EXIST == ret)) {
|
||||
ret = OB_SUCCESS;
|
||||
} else {
|
||||
LOG_WARN("failed to get refactored", K(ret));
|
||||
}
|
||||
} else if (OB_ISNULL(block_num_stat)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected error", K(ret), K(block_num_stat));
|
||||
} else if (OB_FALSE_IT(row_cnt = block_num_stat->sstable_row_cnt_ + block_num_stat->memtable_row_cnt_)) {
|
||||
} else if (row_cnt < param.auto_sample_row_cnt_) {
|
||||
//do nothing
|
||||
} else {
|
||||
need_split_part = true;
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret) && !need_split_part && param.part_stat_param_.need_modify_) {
|
||||
for (int64_t i = 0; OB_SUCC(ret) && !need_split_part && i < param.part_infos_.count(); ++i) {
|
||||
if (OB_FAIL(partition_id_block_map.get_refactored(param.part_infos_.at(i).part_id_, block_num_stat))) {
|
||||
if (OB_LIKELY(OB_HASH_NOT_EXIST == ret)) {
|
||||
ret = OB_SUCCESS;
|
||||
} else {
|
||||
LOG_WARN("failed to get refactored", K(ret));
|
||||
}
|
||||
} else if (OB_ISNULL(block_num_stat)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected error", K(ret), K(block_num_stat));
|
||||
} else if (OB_FALSE_IT(row_cnt = block_num_stat->sstable_row_cnt_ + block_num_stat->memtable_row_cnt_)) {
|
||||
} else if (row_cnt < param.auto_sample_row_cnt_) {
|
||||
//do nothing
|
||||
} else {
|
||||
need_split_part = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
LOG_TRACE("end to adjsut auto gather param", K(param), K(need_split_part));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace common
|
||||
} // namespace oceanbase
|
||||
|
||||
|
@ -209,6 +209,10 @@ private:
|
||||
static bool is_async_gather_partition_id(const int64_t partition_id,
|
||||
const ObIArray<int64_t> *async_partition_ids);
|
||||
|
||||
static int adjust_auto_gather_param(const PartitionIdBlockMap &partition_id_block_map,
|
||||
const ObTableStatParam ¶m,
|
||||
bool &need_split_part);
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "share/stat/ob_index_stats_estimator.h"
|
||||
#include "pl/sys_package/ob_dbms_stats.h"
|
||||
#include "share/stat/ob_opt_stat_gather_stat.h"
|
||||
#include "share/stat/ob_min_max_estimator.h"
|
||||
namespace oceanbase {
|
||||
using namespace pl;
|
||||
namespace common {
|
||||
@ -76,6 +77,30 @@ int ObDbmsStatsGather::gather_stats(ObExecContext &ctx,
|
||||
}
|
||||
}
|
||||
} else {/*do nothing*/}
|
||||
|
||||
if (OB_SUCC(ret) &&
|
||||
param.sample_info_.is_specify_sample() && param.need_refine_min_max_) {
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < opt_stats.count(); ++i) {
|
||||
ObOptStatGatherParam new_param;
|
||||
ObMinMaxEstimator min_max_est(ctx, *param.allocator_);
|
||||
if (OB_ISNULL(opt_stats.at(i).table_stat_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected error", K(ret), K(opt_stats.at(i).table_stat_));
|
||||
} else if (OB_FAIL(THIS_WORKER.check_status())) {
|
||||
LOG_WARN("check status failed", KR(ret));
|
||||
} else if (opt_stats.at(i).table_stat_->get_row_count() <= 0) {
|
||||
//empty table or empty partition, no need gather histogram, just skip.
|
||||
} else if (OB_FAIL(new_param.assign(param))) {
|
||||
LOG_WARN("failed to assign", K(ret));
|
||||
} else if (new_param.stat_level_ != TABLE_LEVEL &&
|
||||
OB_FAIL(ObDbmsStatsUtils::remove_stat_gather_param_partition_info(opt_stats.at(i).table_stat_->get_partition_id(),
|
||||
new_param))) {
|
||||
LOG_WARN("failed to remove stat gather param partition info", K(ret));
|
||||
} else if (OB_FAIL(min_max_est.estimate(new_param, opt_stats.at(i)))) {
|
||||
LOG_WARN("failed to estimate hybrid histogram", K(ret));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -268,16 +293,22 @@ int ObDbmsStatsGather::refine_sample_block_for_async_gather(const ObIArray<ObOpt
|
||||
sstable_row_cnt + memtable_row_cnt > DEFAULT_ASYNC_MAX_SCAN_ROWCOUNT)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected error", K(sstable_row_cnt), K(memtable_row_cnt), K(opt_stats), K(param));
|
||||
} else if (opt_stats.count() == 1) {
|
||||
if (param.async_full_table_size_ < sstable_row_cnt + memtable_row_cnt) {
|
||||
double sample_ratio = 100.0;
|
||||
sample_ratio = 1.0 * param.async_gather_sample_size_ / (sstable_row_cnt + memtable_row_cnt) * 100.0;
|
||||
if (sample_ratio > 0.0 && sample_ratio < 100.0) {
|
||||
param.sample_info_.set_percent(sample_ratio);
|
||||
param.sample_info_.set_is_block_sample(true);
|
||||
}
|
||||
LOG_INFO("decide async gather stats need sample", K(param), K(opt_stats));
|
||||
}
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret) &&
|
||||
(param.is_async_gather_ || param.is_auto_sample_size_) &&
|
||||
!param.sample_info_.is_specify_sample() && opt_stats.count() == 1) {
|
||||
int64_t sstable_row_cnt = opt_stats.at(0).table_stat_->get_sstable_row_count();
|
||||
int64_t memtable_row_cnt = opt_stats.at(0).table_stat_->get_memtable_row_count();
|
||||
if (param.auto_sample_row_cnt_ < sstable_row_cnt + memtable_row_cnt) {
|
||||
double sample_ratio = 100.0;
|
||||
sample_ratio = 1.0 * param.auto_sample_row_cnt_ / (sstable_row_cnt + memtable_row_cnt) * 100.0;
|
||||
if (sample_ratio > 0.0 && sample_ratio < 100.0) {
|
||||
param.sample_info_.set_percent(sample_ratio);
|
||||
param.sample_info_.set_is_block_sample(true);
|
||||
}
|
||||
LOG_INFO("decide auto gather stats need sample", K(param), K(opt_stats));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
@ -67,6 +67,7 @@ const char *windows_name[DAY_OF_WEEK] = {"MONDAY_WINDOW",
|
||||
const char *opt_stats_history_manager = "OPT_STATS_HISTORY_MANAGER";
|
||||
const char *async_gather_stats_job_proc = "ASYNC_GATHER_STATS_JOB_PROC";
|
||||
const int64_t OPT_STATS_HISTORY_MANAGER_JOB_ID = 8;
|
||||
const char *spm_stats_manager = "SPM_STATS_MANAGER";
|
||||
|
||||
int ObDbmsStatsMaintenanceWindow::get_stats_maintenance_window_jobs_sql(const ObSysVariableSchema &sys_variable,
|
||||
const uint64_t tenant_id,
|
||||
@ -180,6 +181,26 @@ int ObDbmsStatsMaintenanceWindow::get_stats_maintenance_window_jobs_sql(const Ob
|
||||
}
|
||||
}
|
||||
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_FAIL(get_spm_stats_job_sql(is_oracle_mode, tenant_id, job_id++,
|
||||
offset_sec, exec_env, tmp_sql))) {
|
||||
LOG_WARN("failed to get stats history manager job sql", K(ret));
|
||||
} else if (OB_FAIL(raw_sql.append_fmt(", (%s)", tmp_sql.ptr()))) {
|
||||
LOG_WARN("failed to append sql", K(ret));
|
||||
} else {
|
||||
++ expected_affected_rows;
|
||||
tmp_sql.reset();
|
||||
if (OB_FAIL(get_spm_stats_job_sql(is_oracle_mode, tenant_id, 0,
|
||||
offset_sec, exec_env, tmp_sql))) {
|
||||
LOG_WARN("failed to get stats history manager job sql", K(ret));
|
||||
} else if (OB_FAIL(raw_sql.append_fmt(", (%s)", tmp_sql.ptr()))) {
|
||||
LOG_WARN("failed to append sql", K(ret));
|
||||
} else {
|
||||
++ expected_affected_rows;
|
||||
tmp_sql.reset();
|
||||
}
|
||||
}
|
||||
|
||||
//set dummy guard job
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_FAIL(get_dummy_guard_job_sql(tenant_id, job_id, tmp_sql))) {
|
||||
@ -364,6 +385,70 @@ int ObDbmsStatsMaintenanceWindow::get_dummy_guard_job_sql(const uint64_t tenant_
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObDbmsStatsMaintenanceWindow::get_spm_stats_job_sql(const bool is_oracle_mode,
|
||||
const uint64_t tenant_id,
|
||||
const int64_t job_id,
|
||||
const int64_t offset_sec,
|
||||
const ObString &exec_env,
|
||||
ObSqlString &raw_sql)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
||||
ObTime ob_time;
|
||||
int64_t current_time = ObTimeUtility::current_time();
|
||||
if (OB_UNLIKELY(current_time <= 0)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected error", K(ret), K(current_time));
|
||||
} else if (OB_FAIL(ObTimeConverter::usec_to_ob_time(current_time + offset_sec * 1000000, ob_time))) {
|
||||
LOG_WARN("failed to usec to ob time", K(ret), K(current_time));
|
||||
} else {
|
||||
// handle spm stats at 1:00 every day
|
||||
int64_t default_start_hour = 1;
|
||||
int64_t total_hour_with_trunc = current_time / USEC_OF_HOUR;
|
||||
int64_t current_hour = ob_time.parts_[DT_HOUR];
|
||||
int64_t offset_hour = 1 * HOUR_OF_DAY + default_start_hour - current_hour;
|
||||
int64_t start_usec = (total_hour_with_trunc + offset_hour) * USEC_OF_HOUR;
|
||||
LOG_INFO("succeed to get spm job info", K(ob_time), K(start_usec), K(offset_hour), K(current_time),
|
||||
K(total_hour_with_trunc), K(current_hour),
|
||||
K(default_start_hour));
|
||||
int64_t interval_ts = DEFAULT_DAY_INTERVAL_USEC;
|
||||
int64_t end_date = 64060560000000000;//4000-01-01 00:00:00.000000
|
||||
share::ObDMLSqlSplicer dml;
|
||||
OZ (dml.add_pk_column("tenant_id", share::schema::ObSchemaUtils::get_extract_tenant_id(tenant_id, tenant_id)));
|
||||
OZ (dml.add_column("job_name", ObHexEscapeSqlStr(ObString(spm_stats_manager))));
|
||||
OZ (dml.add_pk_column("job", job_id));
|
||||
OZ (dml.add_column("lowner", is_oracle_mode ? ObHexEscapeSqlStr("SYS") : ObHexEscapeSqlStr("root@%")));
|
||||
OZ (dml.add_column("powner", is_oracle_mode ? ObHexEscapeSqlStr("SYS") : ObHexEscapeSqlStr("root@%")));
|
||||
OZ (dml.add_column("cowner", is_oracle_mode ? ObHexEscapeSqlStr("SYS") : ObHexEscapeSqlStr("oceanbase")));
|
||||
OZ (dml.add_time_column("next_date", start_usec));
|
||||
OZ (dml.add_column("total", 0));
|
||||
OZ (dml.add_column("`interval#`", ObHexEscapeSqlStr(ObString("FREQ=DAYLY; INTERVAL=1"))));
|
||||
OZ (dml.add_column("flag", 0));
|
||||
OZ (dml.add_column("what", ObHexEscapeSqlStr("DBMS_SPM.HANDLE_SPM_STATS_JOB_PROC()")));
|
||||
OZ (dml.add_column("nlsenv", ObHexEscapeSqlStr(ObString(""))));
|
||||
OZ (dml.add_column("field1", ObHexEscapeSqlStr(ObString(""))));
|
||||
OZ (dml.add_column("exec_env", ObHexEscapeSqlStr(exec_env)));
|
||||
OZ (dml.add_column("job_style", ObHexEscapeSqlStr(ObString("REGULER"))));
|
||||
OZ (dml.add_column("program_name", ObHexEscapeSqlStr(ObString(""))));
|
||||
OZ (dml.add_column("job_type", ObHexEscapeSqlStr(ObString("STORED_PROCEDURE"))));
|
||||
OZ (dml.add_column("job_action", ObHexEscapeSqlStr("DBMS_SPM.HANDLE_SPM_STATS_JOB_PROC()")));
|
||||
OZ (dml.add_column("number_of_argument", 0));
|
||||
OZ (dml.add_raw_time_column("start_date", start_usec));
|
||||
OZ (dml.add_column("repeat_interval", ObHexEscapeSqlStr(ObString("FREQ=DAYLY; INTERVAL=1"))));
|
||||
OZ (dml.add_raw_time_column("end_date", end_date));
|
||||
OZ (dml.add_column("job_class", ObHexEscapeSqlStr(ObString("DEFAULT_JOB_CLASS"))));
|
||||
OZ (dml.add_column("enabled", true));
|
||||
OZ (dml.add_column("auto_drop", false));
|
||||
OZ (dml.add_column("comments", ObHexEscapeSqlStr(ObString("used to handle spm stats"))));
|
||||
OZ (dml.add_column("credential_name", ObHexEscapeSqlStr(ObString(""))));
|
||||
OZ (dml.add_column("destination_name", ObHexEscapeSqlStr(ObString(""))));
|
||||
OZ (dml.add_column("interval_ts", interval_ts));
|
||||
OZ (dml.add_column("max_run_duration", 10 * 60)); // 10 min
|
||||
OZ (dml.splice_values(raw_sql));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* like Oracle, we set 7 windows:
|
||||
* WINDOW_NAME REPEAT_INTERVAL DURATION
|
||||
* MONDAY_WINDOW freq=daily;byday=MON;byhour=22; 4 hours
|
||||
@ -653,11 +738,11 @@ int ObDbmsStatsMaintenanceWindow::get_async_gather_stats_job_for_upgrade(common:
|
||||
bool is_join_exists = false;
|
||||
//bug:
|
||||
ObArenaAllocator allocator("AsyncStatsJob");
|
||||
if (OB_FAIL(check_async_gather_job_exists(sql_proxy, tenant_id, is_join_exists))) {
|
||||
if (OB_FAIL(check_job_exists(sql_proxy, tenant_id, async_gather_stats_job_proc, is_join_exists))) {
|
||||
LOG_WARN("failed to check async gather job exists", K(ret));
|
||||
} else if (is_join_exists) {
|
||||
//do nothing
|
||||
} else if (OB_FAIL(get_async_gather_stats_job_id_and_exec_env(sql_proxy, allocator, tenant_id, job_id, exec_env))) {
|
||||
} else if (OB_FAIL(get_next_job_id_and_exec_env(sql_proxy, allocator, tenant_id, job_id, exec_env))) {
|
||||
LOG_WARN("failed to get async gather stats job id and exec env", K(ret));
|
||||
} else if (OB_UNLIKELY(job_id > dbms_scheduler::ObDBMSSchedTableOperator::JOB_ID_OFFSET ||
|
||||
exec_env.empty())) {
|
||||
@ -684,11 +769,11 @@ int ObDbmsStatsMaintenanceWindow::get_async_gather_stats_job_for_upgrade(common:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObDbmsStatsMaintenanceWindow::get_async_gather_stats_job_id_and_exec_env(common::ObMySQLProxy *sql_proxy,
|
||||
ObIAllocator &allocator,
|
||||
const uint64_t tenant_id,
|
||||
int64_t &job_id,
|
||||
ObString &exec_env)
|
||||
int ObDbmsStatsMaintenanceWindow::get_next_job_id_and_exec_env(common::ObMySQLProxy *sql_proxy,
|
||||
ObIAllocator &allocator,
|
||||
const uint64_t tenant_id,
|
||||
int64_t &job_id,
|
||||
ObString &exec_env)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObSqlString select_sql;
|
||||
@ -748,14 +833,15 @@ int ObDbmsStatsMaintenanceWindow::get_async_gather_stats_job_id_and_exec_env(com
|
||||
}
|
||||
}
|
||||
}
|
||||
LOG_INFO("succeed to get async gather stats job id and exec env", K(ret), K(select_sql), K(job_id), K(exec_env));
|
||||
LOG_INFO("succeed to get next job id and exec env", K(ret), K(select_sql), K(job_id), K(exec_env));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObDbmsStatsMaintenanceWindow::check_async_gather_job_exists(common::ObMySQLProxy *sql_proxy,
|
||||
const uint64_t tenant_id,
|
||||
bool &is_join_exists)
|
||||
int ObDbmsStatsMaintenanceWindow::check_job_exists(common::ObMySQLProxy *sql_proxy,
|
||||
const uint64_t tenant_id,
|
||||
const char* job_name,
|
||||
bool &is_join_exists)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
is_join_exists = false;
|
||||
@ -764,7 +850,7 @@ int ObDbmsStatsMaintenanceWindow::check_async_gather_job_exists(common::ObMySQLP
|
||||
if (OB_FAIL(select_sql.append_fmt("SELECT count(*) FROM %s WHERE tenant_id = %ld and job_name = '%s';",
|
||||
share::OB_ALL_TENANT_SCHEDULER_JOB_TNAME,
|
||||
share::schema::ObSchemaUtils::get_extract_tenant_id(tenant_id, tenant_id),
|
||||
async_gather_stats_job_proc))) {
|
||||
job_name))) {
|
||||
LOG_WARN("failed to append fmt", K(ret));
|
||||
} else {
|
||||
SMART_VAR(ObMySQLProxy::MySQLResult, proxy_result) {
|
||||
@ -801,7 +887,52 @@ int ObDbmsStatsMaintenanceWindow::check_async_gather_job_exists(common::ObMySQLP
|
||||
}
|
||||
}
|
||||
}
|
||||
LOG_INFO("succeed to check async gather job exists", K(ret), K(select_sql), K(is_join_exists), K(row_count));
|
||||
LOG_INFO("succeed to check job exists", K(ret), K(select_sql), K(is_join_exists), K(row_count));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObDbmsStatsMaintenanceWindow::get_spm_stats_upgrade_jobs_sql(common::ObMySQLProxy *sql_proxy,
|
||||
const ObSysVariableSchema &sys_variable,
|
||||
const uint64_t tenant_id,
|
||||
const bool is_oracle_mode,
|
||||
ObSqlString &raw_sql)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
char buf[OB_MAX_PROC_ENV_LENGTH];
|
||||
ObSqlString tmp_sql;
|
||||
int64_t pos = 0;
|
||||
int32_t offset_sec = 0;
|
||||
int64_t job_id = 0;
|
||||
ObString tmp_exec_env;
|
||||
ObArenaAllocator allocator("SpmSchedularJob");
|
||||
if (OB_FAIL(get_next_job_id_and_exec_env(sql_proxy, allocator, tenant_id, job_id, tmp_exec_env))) {
|
||||
LOG_WARN("failed to get async gather stats job id and exec env", K(ret));
|
||||
} else if (OB_UNLIKELY(job_id > dbms_scheduler::ObDBMSSchedTableOperator::JOB_ID_OFFSET ||
|
||||
tmp_exec_env.empty())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected error", K(ret), K(job_id), K(tmp_exec_env));
|
||||
} else if (OB_FAIL(raw_sql.assign_fmt("INSERT INTO %s( "ALL_TENANT_SCHEDULER_JOB_COLUMN_NAME") VALUES ",
|
||||
share::OB_ALL_TENANT_SCHEDULER_JOB_TNAME))) {
|
||||
LOG_WARN("failed to assign fmt", K(ret));
|
||||
} else if (OB_FAIL(sql::ObExecEnv::gen_exec_env(sys_variable, buf, OB_MAX_PROC_ENV_LENGTH, pos))) {
|
||||
LOG_WARN("failed to gen exec env", K(ret));
|
||||
} else if (OB_FAIL(get_time_zone_offset(sys_variable, tenant_id, offset_sec))) {
|
||||
LOG_WARN("failed to get time zone offset", K(ret));
|
||||
} else {
|
||||
ObString exec_env(pos, buf);
|
||||
if (OB_FAIL(get_spm_stats_job_sql(is_oracle_mode, tenant_id, job_id,
|
||||
offset_sec, exec_env, tmp_sql))) {
|
||||
LOG_WARN("failed to get stats history manager job sql", K(ret));
|
||||
} else if (OB_FAIL(raw_sql.append_fmt(" (%s)", tmp_sql.ptr()))) {
|
||||
LOG_WARN("failed to append sql", K(ret));
|
||||
} else if (OB_FALSE_IT(tmp_sql.reset())) {
|
||||
} else if (OB_FAIL(get_spm_stats_job_sql(is_oracle_mode, tenant_id, 0,
|
||||
offset_sec, exec_env, tmp_sql))) {
|
||||
LOG_WARN("failed to get stats history manager job sql", K(ret));
|
||||
} else if (OB_FAIL(raw_sql.append_fmt(", (%s)", tmp_sql.ptr()))) {
|
||||
LOG_WARN("failed to append sql", K(ret));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -61,6 +61,18 @@ public:
|
||||
static int get_async_gather_stats_job_for_upgrade(common::ObMySQLProxy *sql_proxy,
|
||||
const uint64_t tenant_id,
|
||||
ObSqlString &sql);
|
||||
|
||||
static int check_job_exists(common::ObMySQLProxy *sql_proxy,
|
||||
const uint64_t tenant_id,
|
||||
const char* job_name,
|
||||
bool &is_join_exists);
|
||||
|
||||
static int get_spm_stats_upgrade_jobs_sql(common::ObMySQLProxy *sql_proxy,
|
||||
const ObSysVariableSchema &sys_variable,
|
||||
const uint64_t tenant_id,
|
||||
const bool is_oracle_mode,
|
||||
ObSqlString &raw_sql);
|
||||
|
||||
static int get_time_zone_offset(const share::schema::ObSysVariableSchema &sys_variable,
|
||||
const uint64_t tenant_id,
|
||||
int32_t &offset_sec);
|
||||
@ -86,6 +98,12 @@ private:
|
||||
const int64_t job_id,
|
||||
const ObString &exec_env,
|
||||
ObSqlString &raw_sql);
|
||||
static int get_spm_stats_job_sql(const bool is_oracle_mode,
|
||||
const uint64_t tenant_id,
|
||||
const int64_t job_id,
|
||||
const int64_t offset_sec,
|
||||
const ObString &exec_env,
|
||||
ObSqlString &raw_sql);
|
||||
|
||||
static int get_dummy_guard_job_sql(const uint64_t tenant_id,
|
||||
const int64_t job_id,
|
||||
@ -102,14 +120,11 @@ private:
|
||||
const int64_t job_id,
|
||||
const ObString &exec_env,
|
||||
ObSqlString &raw_sql);
|
||||
static int get_async_gather_stats_job_id_and_exec_env(common::ObMySQLProxy *sql_proxy,
|
||||
ObIAllocator &allocator,
|
||||
const uint64_t tenant_id,
|
||||
int64_t &job_id,
|
||||
ObString &exec_env);
|
||||
static int check_async_gather_job_exists(common::ObMySQLProxy *sql_proxy,
|
||||
const uint64_t tenant_id,
|
||||
bool &is_join_exists);
|
||||
static int get_next_job_id_and_exec_env(common::ObMySQLProxy *sql_proxy,
|
||||
ObIAllocator &allocator,
|
||||
const uint64_t tenant_id,
|
||||
int64_t &job_id,
|
||||
ObString &exec_env);
|
||||
|
||||
};
|
||||
|
||||
|
@ -415,7 +415,8 @@ int ObDbmsStatsPreferences::gen_init_global_prefs_sql(ObSqlString &raw_sql,
|
||||
init_perfs_value(ObAsyncGatherFullTableSizePrefs, false/*last value*/);//init async gather full table size
|
||||
init_perfs_value(ObAsyncStaleMaxTableSizePrefs, false/*last value*/);//init async stale max table size
|
||||
init_perfs_value(ObHistEstPercentPrefs, false/*last value*/);//init hist_est_percent
|
||||
init_perfs_value(ObHistBlockSamplePrefs, true/*last value*/);//init hist_block_sample
|
||||
init_perfs_value(ObHistBlockSamplePrefs, false/*last value*/);//init hist_block_sample
|
||||
init_perfs_value(ObAutoSampleRowCountPrefs, true/*last value*/);//init auto_sample_row_count
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_FAIL(raw_sql.append_fmt(INIT_GLOBAL_PREFS,
|
||||
share::OB_ALL_OPTSTAT_GLOBAL_PREFS_TNAME,
|
||||
@ -678,7 +679,9 @@ int ObEstimatePercentPrefs::check_pref_value_validity(ObTableStatParam *param/*d
|
||||
int ret = OB_SUCCESS;
|
||||
if (!pvalue_.empty()) {
|
||||
if (0 == pvalue_.case_compare("DBMS_STATS.AUTO_SAMPLE_SIZE")) {
|
||||
/*do nothing*/
|
||||
if (param != NULL && param->is_auto_gather_) {
|
||||
param->is_auto_sample_size_ = true;
|
||||
}
|
||||
} else {
|
||||
ObObj src_obj;
|
||||
ObObj dest_obj;
|
||||
@ -995,7 +998,7 @@ int ObAsyncGatherSampleSizePrefs::check_pref_value_validity(ObTableStatParam *pa
|
||||
ret = OB_ERR_DBMS_STATS_PL;
|
||||
LOG_WARN("Illegal async gather sample size", K(ret), K(sample_size));
|
||||
} else if (param != NULL) {
|
||||
param->async_gather_sample_size_ = sample_size;
|
||||
|
||||
} else {/*do nothing*/}
|
||||
if (OB_FAIL(ret)) {
|
||||
ret = OB_ERR_DBMS_STATS_PL;
|
||||
@ -1113,6 +1116,38 @@ int ObHistBlockSamplePrefs::check_pref_value_validity(ObTableStatParam *param/*d
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObAutoSampleRowCountPrefs::check_pref_value_validity(ObTableStatParam *param)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (!pvalue_.empty()) {
|
||||
ObObj src_obj;
|
||||
ObObj dest_obj;
|
||||
src_obj.set_string(ObVarcharType, pvalue_);
|
||||
ObArenaAllocator calc_buf("AutoRowCnt");
|
||||
ObCastCtx cast_ctx(&calc_buf, NULL, CM_NONE, ObCharset::get_system_collation());
|
||||
int64_t row_count = 0;
|
||||
int64_t int_part = 0;
|
||||
if (OB_FAIL(ObObjCaster::to_type(ObNumberType, cast_ctx, src_obj, dest_obj))) {
|
||||
LOG_WARN("failed to type", K(ret), K(src_obj));
|
||||
} else if (!dest_obj.get_number().is_valid_int64(int_part)) {
|
||||
ret = OB_ERR_DBMS_STATS_PL;
|
||||
LOG_WARN("Illegal auto sample row count must interger", K(ret));
|
||||
} else if (OB_FAIL(dest_obj.get_number().extract_valid_int64_with_trunc(row_count))) {
|
||||
LOG_WARN("failed to extract valid int64 with trunc", K(ret), K(src_obj));
|
||||
} else if (row_count < -1 || (row_count > 0 && row_count < MAGIC_MIN_SAMPLE_SIZE)) {
|
||||
ret = OB_ERR_DBMS_STATS_PL;
|
||||
LOG_WARN("Illegal auto sample row count must greater than 2500", K(ret), K(row_count));
|
||||
} else if (NULL != param) {
|
||||
param->auto_sample_row_cnt_ = row_count;
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
ret = OB_ERR_DBMS_STATS_PL;
|
||||
LOG_WARN("Illegal auto sample row count", K(ret), K(pvalue_));
|
||||
LOG_USER_ERROR(OB_ERR_DBMS_STATS_PL, "Illegal auto sample row count.");
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#define ISSPACE(c) ((c) == ' ' || (c) == '\n' || (c) == '\r' || (c) == '\t' || (c) == '\f' || (c) == '\v')
|
||||
|
||||
//compatible oracle, global prefs/schema prefs just only can set "for all columns...."
|
||||
@ -1274,5 +1309,30 @@ int ObDbmsStatsPreferences::get_online_estimate_percent_for_upgrade(ObSqlString
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObDbmsStatsPreferences::get_extra_stats_perfs_for_upgrade_425(ObSqlString &raw_sql)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const char *null_str = "NULL";
|
||||
const char *time_str = "CURRENT_TIMESTAMP";
|
||||
ObSqlString value_str;
|
||||
ObAutoSampleRowCountPrefs prefs;
|
||||
if (OB_ISNULL(prefs.get_stat_pref_name()) || OB_ISNULL(prefs.get_stat_pref_default_value())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected error", K(ret), K(prefs.get_stat_pref_name()),
|
||||
K(prefs.get_stat_pref_default_value()));
|
||||
} else if (OB_FAIL(value_str.append_fmt("('%s', %s, %s, '%s');",
|
||||
prefs.get_stat_pref_name(),
|
||||
null_str,
|
||||
time_str,
|
||||
"0"))) {
|
||||
LOG_WARN("failed to append", K(ret));
|
||||
} else if (OB_FAIL(raw_sql.append_fmt(INIT_GLOBAL_PREFS,
|
||||
share::OB_ALL_OPTSTAT_GLOBAL_PREFS_TNAME,
|
||||
value_str.ptr()))) {
|
||||
LOG_WARN("failed to append fmt", K(ret));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace common
|
||||
} // namespace oceanbase
|
||||
|
@ -319,6 +319,19 @@ class ObHistBlockSamplePrefs : public ObStatPrefs
|
||||
virtual const char* get_stat_pref_default_value() const { return "FALSE"; }
|
||||
};
|
||||
|
||||
class ObAutoSampleRowCountPrefs : public ObStatPrefs
|
||||
{
|
||||
public:
|
||||
ObAutoSampleRowCountPrefs() : ObStatPrefs() {}
|
||||
ObAutoSampleRowCountPrefs(ObIAllocator *alloc,
|
||||
ObSQLSessionInfo *session_info,
|
||||
const ObString &pvalue):
|
||||
ObStatPrefs(alloc, session_info, pvalue) {}
|
||||
virtual int check_pref_value_validity(ObTableStatParam *param = NULL) override;
|
||||
virtual const char* get_stat_pref_name() const { return "AUTO_SAMPLE_ROW_COUNT"; }
|
||||
virtual const char* get_stat_pref_default_value() const { return "5000000"; }
|
||||
};
|
||||
|
||||
template <class T>
|
||||
static int new_stat_prefs(ObIAllocator &allocator, ObSQLSessionInfo *session_info,
|
||||
const ObString &opt_value, T *&src)
|
||||
@ -369,6 +382,8 @@ public:
|
||||
|
||||
static int get_extra_stats_perfs_for_upgrade(ObSqlString &sql);
|
||||
|
||||
static int get_extra_stats_perfs_for_upgrade_425(ObSqlString &sql);
|
||||
|
||||
private:
|
||||
static int do_get_prefs(ObMySQLProxy *mysql_proxy,
|
||||
ObIAllocator &allocator,
|
||||
|
@ -1106,12 +1106,14 @@ int ObDbmsStatsUtils::prepare_gather_stat_param(const ObTableStatParam ¶m,
|
||||
gather_param.gather_vectorize_ = gather_vectorize;
|
||||
gather_param.use_column_store_ = use_column_store;
|
||||
gather_param.is_async_gather_ = param.is_async_gather_;
|
||||
gather_param.async_gather_sample_size_ = param.async_gather_sample_size_;
|
||||
gather_param.async_full_table_size_ = param.async_full_table_size_;
|
||||
gather_param.hist_sample_info_.is_sample_ = param.hist_sample_info_.is_sample_;
|
||||
gather_param.hist_sample_info_.is_block_sample_ = param.hist_sample_info_.is_block_sample_;
|
||||
gather_param.hist_sample_info_.sample_type_ = param.hist_sample_info_.sample_type_;
|
||||
gather_param.hist_sample_info_.sample_value_ = param.hist_sample_info_.sample_value_;
|
||||
gather_param.is_auto_sample_size_ = param.is_auto_sample_size_;
|
||||
gather_param.auto_sample_row_cnt_ = param.auto_sample_row_cnt_;
|
||||
gather_param.need_refine_min_max_ = param.need_refine_min_max_;
|
||||
gather_param.is_global_index_ = param.is_global_index_;
|
||||
gather_param.data_table_id_ = param.data_table_id_;
|
||||
gather_param.part_level_ = param.part_level_;
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "pl/sys_package/ob_dbms_stats.h"
|
||||
#include "share/stat/ob_dbms_stats_history_manager.h"
|
||||
#include "share/rc/ob_tenant_base.h"
|
||||
#include "sql/optimizer/ob_opt_selectivity.h"
|
||||
|
||||
namespace oceanbase {
|
||||
using namespace pl;
|
||||
@ -536,6 +537,7 @@ int ObIncrementalStatEstimator::derive_global_tbl_stat(ObIAllocator &alloc,
|
||||
} else {
|
||||
table_stat = new (ptr) ObOptTableStat();
|
||||
ObGlobalTableStat global_tstat;
|
||||
int64_t sample_size = 0;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < part_opt_stats.count(); ++i) {
|
||||
ObOptTableStat *opt_tbl_stat = part_opt_stats.at(i).table_stat_;
|
||||
if (OB_ISNULL(opt_tbl_stat)) {
|
||||
@ -547,6 +549,7 @@ int ObIncrementalStatEstimator::derive_global_tbl_stat(ObIAllocator &alloc,
|
||||
opt_tbl_stat->get_data_size(),
|
||||
opt_tbl_stat->get_macro_block_num(),
|
||||
opt_tbl_stat->get_micro_block_num());
|
||||
sample_size += opt_tbl_stat->get_sample_size();
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
@ -555,7 +558,7 @@ int ObIncrementalStatEstimator::derive_global_tbl_stat(ObIAllocator &alloc,
|
||||
table_stat->set_partition_id(partition_id);
|
||||
table_stat->set_object_type(approx_level);
|
||||
table_stat->set_row_count(global_tstat.get_row_count());
|
||||
table_stat->set_sample_size(global_tstat.get_row_count());
|
||||
table_stat->set_sample_size(sample_size);
|
||||
table_stat->set_avg_row_size(global_tstat.get_avg_row_size());
|
||||
table_stat->set_data_size(global_tstat.get_avg_data_size());
|
||||
table_stat->set_macro_block_num(global_tstat.get_macro_block_count());
|
||||
@ -603,6 +606,8 @@ int ObIncrementalStatEstimator::derive_global_col_stat(ObExecContext &ctx,
|
||||
ObGlobalNdvEval ndv_eval;
|
||||
ObGlobalAvglenEval avglen_eval;
|
||||
ObSEArray<ObHistogram, 4> all_part_histograms;
|
||||
int64_t sample_size = 0;
|
||||
int64_t total_row_cnt = 0;
|
||||
int64_t max_bucket_num = param.column_params_.at(i).bucket_num_;
|
||||
for (int64_t j = 0; OB_SUCC(ret) && j < part_cnt; ++j) {
|
||||
ObOptColumnStat *opt_col_stat = NULL;
|
||||
@ -623,6 +628,8 @@ int ObIncrementalStatEstimator::derive_global_col_stat(ObExecContext &ctx,
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected null", K(ret), K(part_opt_stats.at(j).column_stats_),
|
||||
K(param.column_params_.at(i)));
|
||||
} else if (OB_FALSE_IT(sample_size += opt_tab_stat->get_sample_size())) {
|
||||
} else if (OB_FALSE_IT(total_row_cnt += opt_tab_stat->get_row_count())) {
|
||||
} else if (opt_col_stat->get_num_distinct() == 0 && opt_col_stat->get_num_null() == 0) {
|
||||
/*do nothing*/
|
||||
} else if (need_derive_hist && opt_col_stat->get_histogram().is_valid() &&
|
||||
@ -642,6 +649,7 @@ int ObIncrementalStatEstimator::derive_global_col_stat(ObExecContext &ctx,
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
int64_t num_distinct = ObOptSelectivity::scale_distinct(total_row_cnt, sample_size, ndv_eval.get());
|
||||
col_stat->set_table_id(param.column_params_.at(i).need_basic_stat() ? param.table_id_ : OB_INVALID_ID);
|
||||
col_stat->set_partition_id(partition_id);
|
||||
col_stat->set_column_id(param.column_params_.at(i).column_id_);
|
||||
@ -649,7 +657,7 @@ int ObIncrementalStatEstimator::derive_global_col_stat(ObExecContext &ctx,
|
||||
col_stat->set_num_null(null_eval.get());
|
||||
col_stat->set_num_not_null(not_null_eval.get());
|
||||
col_stat->get_histogram().set_sample_size(not_null_eval.get());
|
||||
col_stat->set_num_distinct(ndv_eval.get());
|
||||
col_stat->set_num_distinct(num_distinct);
|
||||
col_stat->set_avg_len(avglen_eval.get());
|
||||
ndv_eval.get_llc_bitmap(col_stat->get_llc_bitmap(), col_stat->get_llc_bitmap_size());
|
||||
col_stat->set_llc_bitmap_size(ObOptColumnStat::NUM_LLC_BUCKET);
|
||||
|
194
src/share/stat/ob_min_max_estimator.cpp
Normal file
194
src/share/stat/ob_min_max_estimator.cpp
Normal file
@ -0,0 +1,194 @@
|
||||
/**
|
||||
* Copyright (c) 2021 OceanBase
|
||||
* OceanBase CE is licensed under Mulan PubL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||
* You may obtain a copy of Mulan PubL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PubL v2 for more details.
|
||||
*/
|
||||
#define USING_LOG_PREFIX SQL_ENG
|
||||
#include "share/stat/ob_min_max_estimator.h"
|
||||
#include "share/stat/ob_dbms_stats_utils.h"
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace common
|
||||
{
|
||||
|
||||
int ObStatMinMaxSubquery::gen_expr(char *buf, const int64_t buf_len, int64_t &pos)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
char hint[OB_MAX_TABLE_NAME_LENGTH + 10];
|
||||
int64_t hint_pos = 0;
|
||||
if (OB_ISNULL(col_param_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected null", K(ret));
|
||||
} else if (col_param_->index_name_.empty() &&
|
||||
OB_FAIL(databuff_printf(hint, sizeof(hint), hint_pos, "FULL(T)"))) {
|
||||
LOG_WARN("failed to print buf", K(ret));
|
||||
} else if (!col_param_->index_name_.empty() &&
|
||||
OB_FAIL(databuff_printf(hint, sizeof(hint), hint_pos, "INDEX(T %.*s)",
|
||||
col_param_->index_name_.length(),
|
||||
col_param_->index_name_.ptr()))) {
|
||||
LOG_WARN("failed to print buf", K(ret));
|
||||
} else if (OB_FAIL(databuff_printf(buf, buf_len, pos,
|
||||
lib::is_oracle_mode() ?
|
||||
" (SELECT /*+ %.*s */ %.*s FROM \"%.*s\".\"%.*s\" %.*s T WHERE %.*s IS NOT NULL ORDER BY 1 %s FETCH FIRST 1 ROWS ONLY)" :
|
||||
" (SELECT /*+ %.*s */ %.*s FROM `%.*s`.`%.*s` %.*s T WHERE %.*s IS NOT NULL ORDER BY 1 %s LIMIT 1)",
|
||||
(int)hint_pos,
|
||||
hint,
|
||||
col_param_->column_name_.length(),
|
||||
col_param_->column_name_.ptr(),
|
||||
db_name_.length(),
|
||||
db_name_.ptr(),
|
||||
from_table_.length(),
|
||||
from_table_.ptr(),
|
||||
partition_string_.length(),
|
||||
partition_string_.ptr(),
|
||||
col_param_->column_name_.length(),
|
||||
col_param_->column_name_.ptr(),
|
||||
is_min_ ? "ASC" : "DESC"))) {
|
||||
LOG_WARN("failed to print buf", K(ret));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObStatMinMaxSubquery::decode(ObObj &obj, ObIAllocator &allocator)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_ISNULL(col_stat_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("col stat is not given", K(ret), K(col_stat_));
|
||||
} else if (OB_FAIL(ObDbmsStatsUtils::truncate_string_for_opt_stats(obj, allocator))) {
|
||||
LOG_WARN("fail to truncate string", K(ret));
|
||||
} else if (is_min_) {
|
||||
col_stat_->set_min_value(obj);
|
||||
} else {
|
||||
col_stat_->set_max_value(obj);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
ObMinMaxEstimator::ObMinMaxEstimator(ObExecContext &ctx, ObIAllocator &allocator)
|
||||
: ObBasicStatsEstimator(ctx, allocator)
|
||||
{}
|
||||
|
||||
int ObMinMaxEstimator::add_min_max_stat_items(ObIAllocator &allocator,
|
||||
const ObOptStatGatherParam ¶m,
|
||||
const ObIArray<ObColumnStatParam> &column_params,
|
||||
ObOptStat &opt_stat)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_ISNULL(opt_stat.table_stat_) ||
|
||||
OB_UNLIKELY(opt_stat.column_stats_.count() != column_params.count())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected error", K(ret), K(opt_stat), K(column_params));
|
||||
} else {
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < column_params.count(); ++i) {
|
||||
const ObColumnStatParam *col_param = &column_params.at(i);
|
||||
if (OB_ISNULL(opt_stat.column_stats_.at(i)) ||
|
||||
OB_UNLIKELY(col_param->column_id_ != opt_stat.column_stats_.at(i)->get_column_id())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected error", K(ret), KPC(opt_stat.column_stats_.at(i)), KPC(col_param));
|
||||
} else if (!col_param->need_refine_min_max()) {
|
||||
//do nothing
|
||||
} else {
|
||||
void *p = NULL;
|
||||
ObStatMinMaxSubquery *min_subquery = NULL;
|
||||
ObStatMinMaxSubquery *max_subquery = NULL;
|
||||
if (OB_ISNULL(p = allocator.alloc(sizeof(ObStatMinMaxSubquery)))) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("allocate memory failed", K(ret));
|
||||
} else if (OB_FALSE_IT(min_subquery = new(p) ObStatMinMaxSubquery(col_param,
|
||||
opt_stat.column_stats_.at(i),
|
||||
db_name_,
|
||||
from_table_,
|
||||
partition_string_,
|
||||
true))) {
|
||||
} else if (OB_FAIL(stat_items_.push_back(min_subquery))) {
|
||||
LOG_WARN("failed to push back array", K(ret));
|
||||
} else if (OB_ISNULL(p = allocator.alloc(sizeof(ObStatMinMaxSubquery)))) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("allocate memory failed", K(ret));
|
||||
} else if (OB_FALSE_IT(max_subquery = new(p) ObStatMinMaxSubquery(col_param,
|
||||
opt_stat.column_stats_.at(i),
|
||||
db_name_,
|
||||
from_table_,
|
||||
partition_string_,
|
||||
false))) {
|
||||
} else if (OB_FAIL(stat_items_.push_back(max_subquery))) {
|
||||
LOG_WARN("failed to push back array", K(ret));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObMinMaxEstimator::estimate(const ObOptStatGatherParam ¶m,
|
||||
ObOptStat &opt_stat)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObArenaAllocator allocator("ObMinMaxEst", OB_MALLOC_NORMAL_BLOCK_SIZE, param.tenant_id_);
|
||||
ObString no_rewrite("NO_REWRITE USE_PLAN_CACHE(NONE) DBMS_STATS OPT_PARAM('ROWSETS_MAX_ROWS', 256)");
|
||||
ObSqlString raw_sql;
|
||||
int64_t duration_time = -1;
|
||||
ObSEArray<ObOptStat, 1> tmp_opt_stats;
|
||||
if (OB_FAIL(add_from_table(param.db_name_, param.tab_name_))) {
|
||||
LOG_WARN("failed to add from table", K(ret));
|
||||
} else if (OB_UNLIKELY(param.partition_infos_.count() > 1)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected error", K(ret), K(param));
|
||||
} else if (!param.partition_infos_.empty() &&
|
||||
OB_FAIL(fill_partition_info(allocator, param.partition_infos_.at(0).part_name_))) {
|
||||
LOG_WARN("failed to add partition info", K(ret));
|
||||
} else if (OB_FAIL(add_min_max_stat_items(allocator,
|
||||
param,
|
||||
param.column_params_,
|
||||
opt_stat))) {
|
||||
LOG_WARN("failed to add min max stat items", K(ret));
|
||||
} else if (get_item_size() <= 0) {
|
||||
// do nothing
|
||||
} else if (OB_FAIL(add_hint(no_rewrite, allocator))) {
|
||||
LOG_WARN("failed to add no_rewrite", K(ret));
|
||||
} else if (OB_FAIL(ObDbmsStatsUtils::get_valid_duration_time(param.gather_start_time_,
|
||||
param.max_duration_time_,
|
||||
duration_time))) {
|
||||
LOG_WARN("failed to get valid duration time", K(ret));
|
||||
} else if (OB_FAIL(fill_query_timeout_info(allocator, duration_time))) {
|
||||
LOG_WARN("failed to fill query timeout info", K(ret));
|
||||
} else if (OB_FAIL(pack_sql(raw_sql))) {
|
||||
LOG_WARN("failed to pack raw sql", K(ret));
|
||||
} else if (OB_FAIL(tmp_opt_stats.push_back(opt_stat))) {
|
||||
LOG_WARN("failed to push back", K(ret));
|
||||
} else if (OB_FAIL(do_estimate(param.tenant_id_, raw_sql.string(), false,
|
||||
opt_stat, tmp_opt_stats))) {
|
||||
LOG_WARN("failed to evaluate basic stats", K(ret));
|
||||
} else {
|
||||
LOG_TRACE("succeed to gather min max value from index", K(opt_stat.column_stats_));
|
||||
}
|
||||
stat_items_.reuse();
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObMinMaxEstimator::pack_sql(ObSqlString &raw_sql_str)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_FAIL(gen_select_filed())) {
|
||||
LOG_WARN("failed to generate select filed", K(ret));
|
||||
} else if (OB_FAIL(raw_sql_str.append_fmt("SELECT %.*s %.*s FROM DUAL",
|
||||
other_hints_.length(),
|
||||
other_hints_.ptr(),
|
||||
static_cast<int32_t>(select_fields_.length()),
|
||||
select_fields_.ptr()))) {
|
||||
LOG_WARN("failed to build query sql stmt", K(ret));
|
||||
} else {
|
||||
LOG_TRACE("OptStat: min max stat query sql", K(raw_sql_str));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // end of namespace common
|
||||
} // end of namespace oceanbase
|
72
src/share/stat/ob_min_max_estimator.h
Normal file
72
src/share/stat/ob_min_max_estimator.h
Normal file
@ -0,0 +1,72 @@
|
||||
/**
|
||||
* Copyright (c) 2021 OceanBase
|
||||
* OceanBase CE is licensed under Mulan PubL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||
* You may obtain a copy of Mulan PubL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PubL v2 for more details.
|
||||
*/
|
||||
|
||||
#ifndef OB_MIN_MAX_ESTIMATOR_H
|
||||
#define OB_MIN_MAX_ESTIMATOR_H
|
||||
|
||||
#include "share/stat/ob_stat_define.h"
|
||||
#include "share/rc/ob_tenant_base.h"
|
||||
#include "share/stat/ob_basic_stats_estimator.h"
|
||||
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace common
|
||||
{
|
||||
|
||||
class ObStatMinMaxSubquery : public ObStatColItem
|
||||
{
|
||||
public:
|
||||
ObStatMinMaxSubquery() {}
|
||||
ObStatMinMaxSubquery(const ObColumnStatParam *param,
|
||||
ObOptColumnStat *stat,
|
||||
const ObString &db_name,
|
||||
const ObString &from_table,
|
||||
const ObString &partition,
|
||||
bool is_min) :
|
||||
ObStatColItem(param, stat),
|
||||
db_name_(db_name),
|
||||
from_table_(from_table),
|
||||
partition_string_(partition),
|
||||
is_min_(is_min)
|
||||
{}
|
||||
virtual ~ObStatMinMaxSubquery() {}
|
||||
virtual int gen_expr(char *buf, const int64_t buf_len, int64_t &pos) override;
|
||||
virtual int decode(ObObj &obj, ObIAllocator &allocator) override;
|
||||
virtual bool is_needed() const override { return col_param_ != NULL && col_param_->need_refine_min_max(); }
|
||||
private:
|
||||
ObString db_name_;
|
||||
ObString from_table_;
|
||||
ObString partition_string_;
|
||||
bool is_min_;
|
||||
};
|
||||
|
||||
class ObMinMaxEstimator : public ObBasicStatsEstimator
|
||||
{
|
||||
public:
|
||||
explicit ObMinMaxEstimator(ObExecContext &ctx, ObIAllocator &allocator);
|
||||
|
||||
int estimate(const ObOptStatGatherParam ¶m,
|
||||
ObOptStat &opt_stat);
|
||||
|
||||
private:
|
||||
int add_min_max_stat_items(ObIAllocator &allocator,
|
||||
const ObOptStatGatherParam ¶m,
|
||||
const ObIArray<ObColumnStatParam> &column_params,
|
||||
ObOptStat &opt_stat);
|
||||
|
||||
int pack_sql(ObSqlString &raw_sql_str);
|
||||
};
|
||||
|
||||
} // end of namespace common
|
||||
} // end of namespace oceanbase
|
||||
|
||||
#endif /*#endif OB_MIN_MAX_ESTIMATOR_H */
|
@ -241,13 +241,11 @@ public:
|
||||
|
||||
bool is_stat_expired() const { return stale_stats_; }
|
||||
void set_stale_stats(int64_t stale_stats) { stale_stats_ = stale_stats > 0; }
|
||||
|
||||
void add_sample_size(int64_t rc) { sample_size_ += rc; }
|
||||
bool is_locked() const { return stattype_locked_ > 0; }
|
||||
|
||||
void add_row_count(int64_t rc) { row_count_ += rc; }
|
||||
|
||||
void add_sample_size(int64_t rc) { sample_size_ += rc; }
|
||||
|
||||
// for multi rows
|
||||
void add_avg_row_size(double avg_row_size, int64_t rc) {
|
||||
SQL_LOG(DEBUG, "INFO", K(partition_id_));
|
||||
|
@ -183,13 +183,16 @@ int ObTableStatParam::assign(const ObTableStatParam &other)
|
||||
allocator_ = other.allocator_;
|
||||
ref_table_type_ = other.ref_table_type_;
|
||||
is_async_gather_ = other.is_async_gather_;
|
||||
async_gather_sample_size_ = other.async_gather_sample_size_;
|
||||
async_full_table_size_ = other.async_full_table_size_;
|
||||
async_partition_ids_ = other.async_partition_ids_;
|
||||
hist_sample_info_.is_sample_ = other.hist_sample_info_.is_sample_;
|
||||
hist_sample_info_.is_block_sample_ = other.hist_sample_info_.is_block_sample_;
|
||||
hist_sample_info_.sample_type_ = other.hist_sample_info_.sample_type_;
|
||||
hist_sample_info_.sample_value_ = other.hist_sample_info_.sample_value_;
|
||||
is_auto_gather_ = other.is_auto_gather_;
|
||||
is_auto_sample_size_ = other.is_auto_sample_size_;
|
||||
need_refine_min_max_ = other.need_refine_min_max_;
|
||||
auto_sample_row_cnt_ = other.auto_sample_row_cnt_;
|
||||
if (OB_FAIL(part_infos_.assign(other.part_infos_))) {
|
||||
LOG_WARN("failed to assign", K(ret));
|
||||
} else if (OB_FAIL(subpart_infos_.assign(other.subpart_infos_))) {
|
||||
@ -239,6 +242,10 @@ int ObTableStatParam::assign_common_property(const ObTableStatParam &other)
|
||||
hist_sample_info_.is_block_sample_ = other.hist_sample_info_.is_block_sample_;
|
||||
hist_sample_info_.sample_type_ = other.hist_sample_info_.sample_type_;
|
||||
hist_sample_info_.sample_value_ = other.hist_sample_info_.sample_value_;
|
||||
is_auto_gather_ = other.is_auto_gather_;
|
||||
is_auto_sample_size_ = other.is_auto_sample_size_;
|
||||
need_refine_min_max_ = other.need_refine_min_max_;
|
||||
auto_sample_row_cnt_ = other.auto_sample_row_cnt_;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -271,6 +278,9 @@ int ObOptStatGatherParam::assign(const ObOptStatGatherParam &other)
|
||||
hist_sample_info_.is_block_sample_ = other.hist_sample_info_.is_block_sample_;
|
||||
hist_sample_info_.sample_type_ = other.hist_sample_info_.sample_type_;
|
||||
hist_sample_info_.sample_value_ = other.hist_sample_info_.sample_value_;
|
||||
is_auto_sample_size_ = other.is_auto_sample_size_;
|
||||
need_refine_min_max_ = other.need_refine_min_max_;
|
||||
auto_sample_row_cnt_ = other.auto_sample_row_cnt_;
|
||||
data_table_id_ = other.data_table_id_;
|
||||
is_global_index_ = other.is_global_index_;
|
||||
part_level_ = other.part_level_;
|
||||
|
@ -81,6 +81,7 @@ const static int64_t MINIMUM_OF_ASYNC_GATHER_STALE_RATIO = 2;
|
||||
const int64_t MAXIMUM_BLOCK_CNT_OF_ROW_SAMPLE_GATHER_HYBRID_HIST = 100000;
|
||||
const int64_t MAXIMUM_ROWS_OF_ROW_SAMPLE_GATHER_HYBRID_HIST = 10000000;
|
||||
const int64_t MINIMUM_BLOCK_CNT_OF_BLOCK_SAMPLE_HYBRID_HIST = 16;
|
||||
const static int64_t DEFAULT_AUTO_SAMPLE_ROW_COUNT = 0;
|
||||
|
||||
enum StatLevel
|
||||
{
|
||||
@ -425,11 +426,13 @@ struct ObColumnStatParam {
|
||||
inline void set_valid_opt_col() { gather_flag_ |= ColumnGatherFlag::VALID_OPT_COL; }
|
||||
inline void set_need_basic_stat() { gather_flag_ |= ColumnGatherFlag::NEED_BASIC_STAT; }
|
||||
inline void set_need_avg_len() { gather_flag_ |= ColumnGatherFlag::NEED_AVG_LEN; }
|
||||
inline void set_need_refine_min_max() { gather_flag_ |= ColumnGatherFlag::NEED_REFINE_MIN_MAX; }
|
||||
inline bool is_valid_opt_col() const { return gather_flag_ & ColumnGatherFlag::VALID_OPT_COL; }
|
||||
inline bool need_basic_stat() const { return gather_flag_ & ColumnGatherFlag::NEED_BASIC_STAT; }
|
||||
inline bool need_avg_len() const { return gather_flag_ & ColumnGatherFlag::NEED_AVG_LEN; }
|
||||
inline bool need_col_stat() const { return gather_flag_ != ColumnGatherFlag::NO_NEED_STAT; }
|
||||
inline void unset_need_basic_stat() { gather_flag_ &= ~ColumnGatherFlag::NEED_BASIC_STAT; }
|
||||
inline bool need_refine_min_max() const { return gather_flag_ & ColumnGatherFlag::NEED_REFINE_MIN_MAX; }
|
||||
|
||||
ObString column_name_;
|
||||
uint64_t column_id_;
|
||||
@ -440,6 +443,8 @@ struct ObColumnStatParam {
|
||||
int64_t column_attribute_;
|
||||
int64_t column_usage_flag_;
|
||||
int64_t gather_flag_;
|
||||
ObString index_name_;
|
||||
ObObjType column_type_;
|
||||
|
||||
static bool is_valid_opt_col_type(const ObObjType type, bool is_online_stat = false);
|
||||
static bool is_valid_avglen_type(const ObObjType type);
|
||||
@ -452,7 +457,8 @@ struct ObColumnStatParam {
|
||||
K_(bucket_num),
|
||||
K_(column_attribute),
|
||||
K_(column_usage_flag),
|
||||
K_(gather_flag));
|
||||
K_(gather_flag),
|
||||
K_(index_name));
|
||||
};
|
||||
|
||||
struct ObColumnGroupStatParam {
|
||||
@ -540,10 +546,13 @@ struct ObTableStatParam {
|
||||
column_group_params_(),
|
||||
online_sample_percent_(1.),
|
||||
is_async_gather_(false),
|
||||
async_gather_sample_size_(DEFAULT_ASYNC_SAMPLE_SIZE),
|
||||
async_full_table_size_(DEFAULT_ASYNC_FULL_TABLE_SIZE),
|
||||
async_partition_ids_(NULL),
|
||||
hist_sample_info_()
|
||||
hist_sample_info_(),
|
||||
is_auto_gather_(false),
|
||||
is_auto_sample_size_(false),
|
||||
need_refine_min_max_(false),
|
||||
auto_sample_row_cnt_(DEFAULT_AUTO_SAMPLE_ROW_COUNT)
|
||||
{}
|
||||
|
||||
int assign(const ObTableStatParam &other);
|
||||
@ -627,10 +636,13 @@ struct ObTableStatParam {
|
||||
ObArray<ObColumnGroupStatParam> column_group_params_;
|
||||
double online_sample_percent_;
|
||||
bool is_async_gather_;
|
||||
int64_t async_gather_sample_size_;
|
||||
int64_t async_full_table_size_;
|
||||
const ObIArray<int64_t> *async_partition_ids_;
|
||||
ObAnalyzeSampleInfo hist_sample_info_;
|
||||
bool is_auto_gather_;
|
||||
bool is_auto_sample_size_;
|
||||
bool need_refine_min_max_;
|
||||
int64_t auto_sample_row_cnt_;
|
||||
ObSEArray<PrefixColumnPair, 4> prefix_column_pairs_;
|
||||
|
||||
TO_STRING_KV(K(tenant_id_),
|
||||
@ -678,10 +690,12 @@ struct ObTableStatParam {
|
||||
K(column_group_params_),
|
||||
K(online_sample_percent_),
|
||||
K(is_async_gather_),
|
||||
K(async_gather_sample_size_),
|
||||
K(async_full_table_size_),
|
||||
KPC(async_partition_ids_),
|
||||
K(hist_sample_info_),
|
||||
K(is_auto_gather_),
|
||||
K(need_refine_min_max_),
|
||||
K(is_auto_sample_size_),
|
||||
K(prefix_column_pairs_));
|
||||
};
|
||||
|
||||
@ -712,9 +726,11 @@ struct ObOptStatGatherParam {
|
||||
use_column_store_(false),
|
||||
is_specify_partition_(false),
|
||||
is_async_gather_(false),
|
||||
async_gather_sample_size_(DEFAULT_ASYNC_SAMPLE_SIZE),
|
||||
async_full_table_size_(DEFAULT_ASYNC_FULL_TABLE_SIZE),
|
||||
hist_sample_info_(),
|
||||
is_auto_sample_size_(false),
|
||||
need_refine_min_max_(false),
|
||||
auto_sample_row_cnt_(DEFAULT_AUTO_SAMPLE_ROW_COUNT),
|
||||
data_table_id_(OB_INVALID_ID),
|
||||
is_global_index_(false),
|
||||
part_level_(share::schema::ObPartitionLevel::PARTITION_LEVEL_ZERO)
|
||||
@ -746,9 +762,11 @@ struct ObOptStatGatherParam {
|
||||
bool use_column_store_;
|
||||
bool is_specify_partition_;
|
||||
int64_t is_async_gather_;
|
||||
int64_t async_gather_sample_size_;
|
||||
int64_t async_full_table_size_;
|
||||
ObAnalyzeSampleInfo hist_sample_info_;
|
||||
bool is_auto_sample_size_;
|
||||
bool need_refine_min_max_;
|
||||
int64_t auto_sample_row_cnt_;
|
||||
uint64_t data_table_id_;
|
||||
bool is_global_index_;
|
||||
share::schema::ObPartitionLevel part_level_;
|
||||
@ -776,9 +794,11 @@ struct ObOptStatGatherParam {
|
||||
K(use_column_store_),
|
||||
K(is_specify_partition_),
|
||||
K(is_async_gather_),
|
||||
K(async_gather_sample_size_),
|
||||
K(async_full_table_size_),
|
||||
K(hist_sample_info_),
|
||||
K(is_auto_sample_size_),
|
||||
K(need_refine_min_max_),
|
||||
K(auto_sample_row_cnt_),
|
||||
K(data_table_id_),
|
||||
K(is_global_index_));
|
||||
};
|
||||
|
@ -753,5 +753,97 @@ int ObStatHybridHist::decode(ObObj &obj, ObIAllocator &allocator)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const int32_t DEFAULT_DATA_TYPE_LEGNTH[] =
|
||||
{
|
||||
/*ObNullType = 0*/ 12,
|
||||
/*ObTinyIntType = 1*/ 20,
|
||||
/*ObSmallIntType = 2*/ 20,
|
||||
/*ObMediumIntType = 3*/ 20,
|
||||
/*ObInt32Type = 4*/ 20,
|
||||
/*ObIntType = 5*/ 20,
|
||||
|
||||
/*ObUTinyIntType = 6*/ 20,
|
||||
/*ObUSmallIntType = 7*/ 20,
|
||||
/*ObUMediumIntType = 8*/ 20,
|
||||
/*ObUInt32Type = 9*/ 20,
|
||||
/*ObUInt64Type = 10*/ 20,
|
||||
|
||||
/*ObFloatType = 11*/ 16,
|
||||
/*ObDoubleType = 12*/ 20,
|
||||
|
||||
/*ObUFloatType = 13*/ 16,
|
||||
/*ObUDoubleType = 14*/ 20,
|
||||
|
||||
/*ObNumberType = 15*/ -1,
|
||||
/*ObUNumberType = 16*/ -1,
|
||||
|
||||
/*ObDateTimeType = 17*/ 20,
|
||||
/*ObTimestampType = 18*/ 20,
|
||||
/*ObDateType = 19*/ 16,
|
||||
/*ObTimeType = 20*/ 20,
|
||||
/*ObYearType = 21*/ 13,
|
||||
|
||||
/*ObVarcharType = 22*/ -1,
|
||||
/*ObCharType = 23*/ -1,
|
||||
|
||||
/*ObHexStringType = 24*/ -1,
|
||||
|
||||
/*ObExtendType = 25*/ -1,
|
||||
/*ObUnknownType = 26*/ -1,
|
||||
|
||||
/*ObTinyTextType = 27*/ -1,
|
||||
/*ObTextType = 28*/ -1,
|
||||
/*ObMediumTextType = 29*/ -1,
|
||||
/*ObLongTextType = 30*/ -1,
|
||||
|
||||
/*ObBitType = 31*/ 20,
|
||||
/*ObEnumType = 32*/ 20,
|
||||
/*ObSetType = 33*/ 20,
|
||||
/*ObEnumInnerType = 34*/ -1,
|
||||
/*ObSetInnerType = 35*/ -1,
|
||||
|
||||
/*ObTimestampTZType = 36*/ 24,
|
||||
/*ObTimestampLTZType = 37*/ 22,
|
||||
/*ObTimestampNanoType = 38*/ 22,
|
||||
/*ObRawType = 39*/ -1,
|
||||
/*ObIntervalYMType = 40*/ -1,
|
||||
/*ObIntervalDSType = 41*/ -1,
|
||||
/*ObNumberFloatType = 42*/ -1,
|
||||
/*ObNVarchar2Type = 43*/ -1,
|
||||
/*ObNCharType = 44*/ -1,
|
||||
/*ObURowIDType = 45*/ -1,
|
||||
/*ObLobType = 46*/ -1,
|
||||
/*ObJsonType = 47*/ -1,
|
||||
/*ObGeometryType = 48*/ -1,
|
||||
|
||||
/*ObUserDefinedSQLType = 49*/ -1,
|
||||
/*ObDecimalIntType = 50*/ -1,
|
||||
/*ObCollectionSQLType = 51*/ -1,
|
||||
/*ObMySQLDateType = 52*/ 16,
|
||||
/*ObMySQLDateTimeType = 53*/ 20,
|
||||
/*ObMaxType */ -1
|
||||
};
|
||||
|
||||
int ObStatAvgLen::gen_expr(char *buf, const int64_t buf_len, int64_t &pos)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int64_t type_count = sizeof(DEFAULT_DATA_TYPE_LEGNTH) / sizeof(int32_t);
|
||||
if (OB_ISNULL(col_param_) || OB_ISNULL(get_fmt())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("column param is null", K(ret));
|
||||
} else if (col_param_->column_type_ < type_count &&
|
||||
DEFAULT_DATA_TYPE_LEGNTH[col_param_->column_type_] > 0) {
|
||||
if (OB_FAIL(databuff_printf(buf, buf_len, pos, "%d",
|
||||
DEFAULT_DATA_TYPE_LEGNTH[col_param_->column_type_]))) {
|
||||
LOG_WARN("failed to print avg column size", K(ret));
|
||||
}
|
||||
} else if (OB_FAIL(databuff_printf(buf, buf_len, pos, get_fmt(),
|
||||
col_param_->column_name_.length(),
|
||||
col_param_->column_name_.ptr()))) {
|
||||
LOG_WARN("failed to print AVG(SYS_OP_OPNSIZE(c2)) expr", K(ret));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // end of common
|
||||
} // end of oceanbase
|
||||
|
@ -202,6 +202,7 @@ public:
|
||||
return lib::is_oracle_mode() ? " SUM_OPNSIZE(\"%.*s\")/decode(COUNT(*),0,1,COUNT(*))" : " SUM_OPNSIZE(`%.*s`)/(case when COUNT(*) = 0 then 1 else COUNT(*) end)";
|
||||
}
|
||||
virtual int decode(ObObj &obj) override;
|
||||
virtual int gen_expr(char *buf, const int64_t buf_len, int64_t &pos) override;
|
||||
};
|
||||
|
||||
class ObStatLlcBitmap : public ObStatColItem
|
||||
|
@ -627,6 +627,7 @@ enum ObSysVarClassType
|
||||
SYS_VAR_DELAYED_INSERT_LIMIT = 10736,
|
||||
SYS_VAR_NDB_VERSION = 10737,
|
||||
SYS_VAR_AUTO_GENERATE_CERTS = 10738,
|
||||
SYS_VAR__OPTIMIZER_COST_BASED_TRANSFORMATION = 10739,
|
||||
SYS_VAR_RANGE_INDEX_DIVE_LIMIT = 10740,
|
||||
SYS_VAR_PARTITION_INDEX_DIVE_LIMIT = 10741,
|
||||
SYS_VAR_OB_TABLE_ACCESS_POLICY = 10742,
|
||||
|
@ -622,6 +622,7 @@ namespace share
|
||||
static const char* const OB_SV_DELAYED_INSERT_LIMIT = "delayed_insert_limit";
|
||||
static const char* const OB_SV_NDB_VERSION = "ndb_version";
|
||||
static const char* const OB_SV_AUTO_GENERATE_CERTS = "auto_generate_certs";
|
||||
static const char* const OB_SV__OPTIMIZER_COST_BASED_TRANSFORMATION = "_optimizer_cost_based_transformation";
|
||||
static const char* const OB_SV_RANGE_INDEX_DIVE_LIMIT = "range_index_dive_limit";
|
||||
static const char* const OB_SV_PARTITION_INDEX_DIVE_LIMIT = "partition_index_dive_limit";
|
||||
static const char* const OB_SV_TABLE_ACCESS_POLICY = "ob_table_access_policy";
|
||||
|
@ -539,6 +539,7 @@ const char *ObSysVarFactory::SYS_VAR_NAMES_SORTED_BY_NAME[] = {
|
||||
"_ob_proxy_weakread_feedback",
|
||||
"_ob_px_bcast_optimization",
|
||||
"_ob_px_slave_mapping_threshold",
|
||||
"_optimizer_cost_based_transformation",
|
||||
"_optimizer_gather_stats_on_load",
|
||||
"_optimizer_null_aware_antijoin",
|
||||
"_oracle_sql_select_limit",
|
||||
@ -1151,6 +1152,7 @@ const ObSysVarClassType ObSysVarFactory::SYS_VAR_IDS_SORTED_BY_NAME[] = {
|
||||
SYS_VAR__OB_PROXY_WEAKREAD_FEEDBACK,
|
||||
SYS_VAR__OB_PX_BCAST_OPTIMIZATION,
|
||||
SYS_VAR__OB_PX_SLAVE_MAPPING_THRESHOLD,
|
||||
SYS_VAR__OPTIMIZER_COST_BASED_TRANSFORMATION,
|
||||
SYS_VAR__OPTIMIZER_GATHER_STATS_ON_LOAD,
|
||||
SYS_VAR__OPTIMIZER_NULL_AWARE_ANTIJOIN,
|
||||
SYS_VAR__ORACLE_SQL_SELECT_LIMIT,
|
||||
@ -2346,6 +2348,7 @@ const char *ObSysVarFactory::SYS_VAR_NAMES_SORTED_BY_ID[] = {
|
||||
"delayed_insert_limit",
|
||||
"ndb_version",
|
||||
"auto_generate_certs",
|
||||
"_optimizer_cost_based_transformation",
|
||||
"range_index_dive_limit",
|
||||
"partition_index_dive_limit",
|
||||
"ob_table_access_policy"
|
||||
@ -3159,6 +3162,7 @@ int ObSysVarFactory::create_all_sys_vars()
|
||||
+ sizeof(ObSysVarDelayedInsertLimit)
|
||||
+ sizeof(ObSysVarNdbVersion)
|
||||
+ sizeof(ObSysVarAutoGenerateCerts)
|
||||
+ sizeof(ObSysVarOptimizerCostBasedTransformation)
|
||||
+ sizeof(ObSysVarRangeIndexDiveLimit)
|
||||
+ sizeof(ObSysVarPartitionIndexDiveLimit)
|
||||
+ sizeof(ObSysVarObTableAccessPolicy)
|
||||
@ -8624,6 +8628,15 @@ int ObSysVarFactory::create_all_sys_vars()
|
||||
ptr = (void *)((char *)ptr + sizeof(ObSysVarAutoGenerateCerts));
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_ISNULL(sys_var_ptr = new (ptr)ObSysVarOptimizerCostBasedTransformation())) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_ERROR("fail to new ObSysVarOptimizerCostBasedTransformation", K(ret));
|
||||
} else {
|
||||
store_buf_[ObSysVarsToIdxMap::get_store_idx(static_cast<int64_t>(SYS_VAR__OPTIMIZER_COST_BASED_TRANSFORMATION))] = sys_var_ptr;
|
||||
ptr = (void *)((char *)ptr + sizeof(ObSysVarOptimizerCostBasedTransformation));
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_ISNULL(sys_var_ptr = new (ptr)ObSysVarRangeIndexDiveLimit())) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
@ -15327,6 +15340,17 @@ int ObSysVarFactory::create_sys_var(ObIAllocator &allocator_, ObSysVarClassType
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SYS_VAR__OPTIMIZER_COST_BASED_TRANSFORMATION: {
|
||||
void *ptr = NULL;
|
||||
if (OB_ISNULL(ptr = allocator_.alloc(sizeof(ObSysVarOptimizerCostBasedTransformation)))) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_ERROR("fail to alloc memory", K(ret), K(sizeof(ObSysVarOptimizerCostBasedTransformation)));
|
||||
} else if (OB_ISNULL(sys_var_ptr = new (ptr)ObSysVarOptimizerCostBasedTransformation())) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_ERROR("fail to new ObSysVarOptimizerCostBasedTransformation", K(ret));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SYS_VAR_RANGE_INDEX_DIVE_LIMIT: {
|
||||
void *ptr = NULL;
|
||||
if (OB_ISNULL(ptr = allocator_.alloc(sizeof(ObSysVarRangeIndexDiveLimit)))) {
|
||||
|
@ -4421,19 +4421,26 @@ public:
|
||||
inline virtual ObSysVarClassType get_type() const { return SYS_VAR_AUTO_GENERATE_CERTS; }
|
||||
inline virtual const common::ObObj &get_global_default_value() const { return ObSysVariables::get_default_value(605); }
|
||||
};
|
||||
class ObSysVarOptimizerCostBasedTransformation : public ObIntSysVar
|
||||
{
|
||||
public:
|
||||
ObSysVarOptimizerCostBasedTransformation() : ObIntSysVar(NULL, NULL, NULL, NULL, NULL) {}
|
||||
inline virtual ObSysVarClassType get_type() const { return SYS_VAR__OPTIMIZER_COST_BASED_TRANSFORMATION; }
|
||||
inline virtual const common::ObObj &get_global_default_value() const { return ObSysVariables::get_default_value(606); }
|
||||
};
|
||||
class ObSysVarRangeIndexDiveLimit : public ObIntSysVar
|
||||
{
|
||||
public:
|
||||
ObSysVarRangeIndexDiveLimit() : ObIntSysVar(NULL, NULL, NULL, NULL, NULL) {}
|
||||
inline virtual ObSysVarClassType get_type() const { return SYS_VAR_RANGE_INDEX_DIVE_LIMIT; }
|
||||
inline virtual const common::ObObj &get_global_default_value() const { return ObSysVariables::get_default_value(606); }
|
||||
inline virtual const common::ObObj &get_global_default_value() const { return ObSysVariables::get_default_value(607); }
|
||||
};
|
||||
class ObSysVarPartitionIndexDiveLimit : public ObIntSysVar
|
||||
{
|
||||
public:
|
||||
ObSysVarPartitionIndexDiveLimit() : ObIntSysVar(NULL, NULL, NULL, NULL, NULL) {}
|
||||
inline virtual ObSysVarClassType get_type() const { return SYS_VAR_PARTITION_INDEX_DIVE_LIMIT; }
|
||||
inline virtual const common::ObObj &get_global_default_value() const { return ObSysVariables::get_default_value(607); }
|
||||
inline virtual const common::ObObj &get_global_default_value() const { return ObSysVariables::get_default_value(608); }
|
||||
};
|
||||
class ObSysVarObTableAccessPolicy : public ObEnumSysVar
|
||||
{
|
||||
@ -4442,7 +4449,7 @@ public:
|
||||
public:
|
||||
ObSysVarObTableAccessPolicy() : ObEnumSysVar(OB_TABLE_ACCESS_POLICY_NAMES, NULL, NULL, NULL, NULL, NULL) {}
|
||||
inline virtual ObSysVarClassType get_type() const { return SYS_VAR_OB_TABLE_ACCESS_POLICY; }
|
||||
inline virtual const common::ObObj &get_global_default_value() const { return ObSysVariables::get_default_value(608); }
|
||||
inline virtual const common::ObObj &get_global_default_value() const { return ObSysVariables::get_default_value(609); }
|
||||
};
|
||||
|
||||
|
||||
@ -4467,7 +4474,7 @@ private:
|
||||
|
||||
public:
|
||||
const static int64_t MYSQL_SYS_VARS_COUNT = 99;
|
||||
const static int64_t OB_SYS_VARS_COUNT = 510;
|
||||
const static int64_t OB_SYS_VARS_COUNT = 511;
|
||||
const static int64_t ALL_SYS_VARS_COUNT = MYSQL_SYS_VARS_COUNT + OB_SYS_VARS_COUNT;
|
||||
const static int64_t INVALID_MAX_READ_STALE_TIME = -1;
|
||||
|
||||
|
@ -3308,7 +3308,7 @@ static struct VarsInit{
|
||||
}();
|
||||
|
||||
[&] (){
|
||||
ObSysVars[234].default_value_ = "4.3.4.0" ;
|
||||
ObSysVars[234].default_value_ = "4.3.5.0" ;
|
||||
ObSysVars[234].info_ = "enabling a series of optimizer features based on an OceanBase release number" ;
|
||||
ObSysVars[234].name_ = "optimizer_features_enable" ;
|
||||
ObSysVars[234].data_type_ = ObVarcharType ;
|
||||
@ -8441,43 +8441,58 @@ static struct VarsInit{
|
||||
}();
|
||||
|
||||
[&] (){
|
||||
ObSysVars[606].default_value_ = "10" ;
|
||||
ObSysVars[606].info_ = "Indicate the limit on the number of ranges when optimizer use storage cardinality estimation" ;
|
||||
ObSysVars[606].name_ = "range_index_dive_limit" ;
|
||||
ObSysVars[606].default_value_ = "1" ;
|
||||
ObSysVars[606].info_ = "control cost-based transformation search policy" ;
|
||||
ObSysVars[606].name_ = "_optimizer_cost_based_transformation" ;
|
||||
ObSysVars[606].data_type_ = ObIntType ;
|
||||
ObSysVars[606].flags_ = ObSysVarFlag::SESSION_SCOPE | ObSysVarFlag::GLOBAL_SCOPE ;
|
||||
ObSysVars[606].id_ = SYS_VAR_RANGE_INDEX_DIVE_LIMIT ;
|
||||
cur_max_var_id = MAX(cur_max_var_id, static_cast<int64_t>(SYS_VAR_RANGE_INDEX_DIVE_LIMIT)) ;
|
||||
ObSysVarsIdToArrayIdx[SYS_VAR_RANGE_INDEX_DIVE_LIMIT] = 606 ;
|
||||
ObSysVars[606].base_value_ = "10" ;
|
||||
ObSysVars[606].alias_ = "OB_SV_RANGE_INDEX_DIVE_LIMIT" ;
|
||||
ObSysVars[606].min_val_ = "0" ;
|
||||
ObSysVars[606].max_val_ = "2" ;
|
||||
ObSysVars[606].flags_ = ObSysVarFlag::GLOBAL_SCOPE | ObSysVarFlag::SESSION_SCOPE ;
|
||||
ObSysVars[606].id_ = SYS_VAR__OPTIMIZER_COST_BASED_TRANSFORMATION ;
|
||||
cur_max_var_id = MAX(cur_max_var_id, static_cast<int64_t>(SYS_VAR__OPTIMIZER_COST_BASED_TRANSFORMATION)) ;
|
||||
ObSysVarsIdToArrayIdx[SYS_VAR__OPTIMIZER_COST_BASED_TRANSFORMATION] = 606 ;
|
||||
ObSysVars[606].base_value_ = "1" ;
|
||||
ObSysVars[606].alias_ = "OB_SV__OPTIMIZER_COST_BASED_TRANSFORMATION" ;
|
||||
}();
|
||||
|
||||
[&] (){
|
||||
ObSysVars[607].default_value_ = "10" ;
|
||||
ObSysVars[607].info_ = "Indicate the limit on the number of partitions when optimizer use storage cardinality estimation" ;
|
||||
ObSysVars[607].name_ = "partition_index_dive_limit" ;
|
||||
ObSysVars[607].info_ = "Indicate the limit on the number of ranges when optimizer use storage cardinality estimation" ;
|
||||
ObSysVars[607].name_ = "range_index_dive_limit" ;
|
||||
ObSysVars[607].data_type_ = ObIntType ;
|
||||
ObSysVars[607].flags_ = ObSysVarFlag::SESSION_SCOPE | ObSysVarFlag::GLOBAL_SCOPE ;
|
||||
ObSysVars[607].id_ = SYS_VAR_PARTITION_INDEX_DIVE_LIMIT ;
|
||||
cur_max_var_id = MAX(cur_max_var_id, static_cast<int64_t>(SYS_VAR_PARTITION_INDEX_DIVE_LIMIT)) ;
|
||||
ObSysVarsIdToArrayIdx[SYS_VAR_PARTITION_INDEX_DIVE_LIMIT] = 607 ;
|
||||
ObSysVars[607].id_ = SYS_VAR_RANGE_INDEX_DIVE_LIMIT ;
|
||||
cur_max_var_id = MAX(cur_max_var_id, static_cast<int64_t>(SYS_VAR_RANGE_INDEX_DIVE_LIMIT)) ;
|
||||
ObSysVarsIdToArrayIdx[SYS_VAR_RANGE_INDEX_DIVE_LIMIT] = 607 ;
|
||||
ObSysVars[607].base_value_ = "10" ;
|
||||
ObSysVars[607].alias_ = "OB_SV_PARTITION_INDEX_DIVE_LIMIT" ;
|
||||
ObSysVars[607].alias_ = "OB_SV_RANGE_INDEX_DIVE_LIMIT" ;
|
||||
}();
|
||||
|
||||
[&] (){
|
||||
ObSysVars[608].default_value_ = "2" ;
|
||||
ObSysVars[608].info_ = "Control the optimizer to generate a table access plan that prefers a specific storage format." ;
|
||||
ObSysVars[608].name_ = "ob_table_access_policy" ;
|
||||
ObSysVars[608].default_value_ = "10" ;
|
||||
ObSysVars[608].info_ = "Indicate the limit on the number of partitions when optimizer use storage cardinality estimation" ;
|
||||
ObSysVars[608].name_ = "partition_index_dive_limit" ;
|
||||
ObSysVars[608].data_type_ = ObIntType ;
|
||||
ObSysVars[608].enum_names_ = "[u'ROW_STORE', u'COLUMN_STORE', u'AUTO']" ;
|
||||
ObSysVars[608].flags_ = ObSysVarFlag::GLOBAL_SCOPE | ObSysVarFlag::SESSION_SCOPE | ObSysVarFlag::INFLUENCE_PLAN | ObSysVarFlag::NEED_SERIALIZE ;
|
||||
ObSysVars[608].id_ = SYS_VAR_OB_TABLE_ACCESS_POLICY ;
|
||||
ObSysVars[608].flags_ = ObSysVarFlag::SESSION_SCOPE | ObSysVarFlag::GLOBAL_SCOPE ;
|
||||
ObSysVars[608].id_ = SYS_VAR_PARTITION_INDEX_DIVE_LIMIT ;
|
||||
cur_max_var_id = MAX(cur_max_var_id, static_cast<int64_t>(SYS_VAR_PARTITION_INDEX_DIVE_LIMIT)) ;
|
||||
ObSysVarsIdToArrayIdx[SYS_VAR_PARTITION_INDEX_DIVE_LIMIT] = 608 ;
|
||||
ObSysVars[608].base_value_ = "10" ;
|
||||
ObSysVars[608].alias_ = "OB_SV_PARTITION_INDEX_DIVE_LIMIT" ;
|
||||
}();
|
||||
|
||||
[&] (){
|
||||
ObSysVars[609].default_value_ = "2" ;
|
||||
ObSysVars[609].info_ = "Control the optimizer to generate a table access plan that prefers a specific storage format." ;
|
||||
ObSysVars[609].name_ = "ob_table_access_policy" ;
|
||||
ObSysVars[609].data_type_ = ObIntType ;
|
||||
ObSysVars[609].enum_names_ = "[u'ROW_STORE', u'COLUMN_STORE', u'AUTO']" ;
|
||||
ObSysVars[609].flags_ = ObSysVarFlag::GLOBAL_SCOPE | ObSysVarFlag::SESSION_SCOPE | ObSysVarFlag::INFLUENCE_PLAN | ObSysVarFlag::NEED_SERIALIZE ;
|
||||
ObSysVars[609].id_ = SYS_VAR_OB_TABLE_ACCESS_POLICY ;
|
||||
cur_max_var_id = MAX(cur_max_var_id, static_cast<int64_t>(SYS_VAR_OB_TABLE_ACCESS_POLICY)) ;
|
||||
ObSysVarsIdToArrayIdx[SYS_VAR_OB_TABLE_ACCESS_POLICY] = 608 ;
|
||||
ObSysVars[608].base_value_ = "2" ;
|
||||
ObSysVars[608].alias_ = "OB_SV_TABLE_ACCESS_POLICY" ;
|
||||
ObSysVarsIdToArrayIdx[SYS_VAR_OB_TABLE_ACCESS_POLICY] = 609 ;
|
||||
ObSysVars[609].base_value_ = "2" ;
|
||||
ObSysVars[609].alias_ = "OB_SV_TABLE_ACCESS_POLICY" ;
|
||||
}();
|
||||
|
||||
if (cur_max_var_id >= ObSysVarFactory::OB_MAX_SYS_VAR_ID) {
|
||||
@ -8486,7 +8501,7 @@ static struct VarsInit{
|
||||
}
|
||||
}vars_init;
|
||||
|
||||
static int64_t var_amount = 609;
|
||||
static int64_t var_amount = 610;
|
||||
|
||||
int64_t ObSysVariables::get_all_sys_var_count(){ return ObSysVarFactory::ALL_SYS_VARS_COUNT;}
|
||||
ObSysVarClassType ObSysVariables::get_sys_var_id(int64_t i){ return ObSysVars[i].id_;}
|
||||
|
@ -3349,7 +3349,7 @@
|
||||
"optimizer_features_enable": {
|
||||
"id": 10150,
|
||||
"name": "optimizer_features_enable",
|
||||
"default_value": "4.3.4.0",
|
||||
"default_value": "4.3.5.0",
|
||||
"base_value": "",
|
||||
"data_type": "varchar",
|
||||
"info": "enabling a series of optimizer features based on an OceanBase release number",
|
||||
@ -11825,8 +11825,7 @@
|
||||
"publish_version": "425",
|
||||
"info_cn": "",
|
||||
"background_cn": "",
|
||||
"ref_url": "",
|
||||
"placeholder": true
|
||||
"ref_url": ""
|
||||
},
|
||||
"range_index_dive_limit": {
|
||||
"id": 10740,
|
||||
|
@ -1380,7 +1380,6 @@ ob_set_subtarget(ob_sql resolver_prepare
|
||||
|
||||
ob_set_subtarget(ob_sql rewrite
|
||||
rewrite/ob_equal_analysis.cpp
|
||||
rewrite/ob_equal_set.ipp
|
||||
rewrite/ob_expand_aggregate_utils.cpp
|
||||
rewrite/ob_key_part.cpp
|
||||
rewrite/ob_predicate_deduce.cpp
|
||||
@ -1427,6 +1426,7 @@ ob_set_subtarget(ob_sql rewrite
|
||||
rewrite/ob_transform_decorrelate.cpp
|
||||
rewrite/ob_transform_late_materialization.cpp
|
||||
rewrite/ob_transform_mv_rewrite_prepare.cpp
|
||||
rewrite/ob_transform_distinct_aggregate.cpp
|
||||
)
|
||||
|
||||
ob_set_subtarget(ob_sql session
|
||||
|
@ -4797,7 +4797,7 @@ int ObStaticEngineCG::generate_spec(ObLogGroupBy &op, ObMergeGroupBySpec &spec,
|
||||
}
|
||||
if ((!op.get_group_by_exprs().empty() || !op.get_rollup_exprs().empty())
|
||||
&& SCALAR_AGGREGATE != op.get_algo()) {
|
||||
double distinct_card = MAX(1.0, op.get_distinct_card());
|
||||
double distinct_card = MAX(1.0, op.get_total_ndv());
|
||||
spec.est_rows_per_group_ = ceil(op.get_origin_child_card() / distinct_card);
|
||||
}
|
||||
spec.set_rollup(op.has_rollup());
|
||||
@ -5066,7 +5066,7 @@ int ObStaticEngineCG::generate_spec(ObLogGroupBy &op, ObHashGroupBySpec &spec,
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_ERROR("wrong number of children", K(ret), K(op.get_num_of_child()));
|
||||
} else {
|
||||
spec.set_est_group_cnt(op.get_distinct_card());
|
||||
spec.set_est_group_cnt(op.get_total_ndv());
|
||||
OZ(set_3stage_info(op, spec));
|
||||
spec.by_pass_enabled_ = op.is_adaptive_aggregate();
|
||||
int64_t tenant_id = op.get_plan()->get_optimizer_context().get_session_info()->get_effective_tenant_id();
|
||||
|
@ -211,7 +211,7 @@ int ObLoadDataBase::make_parameterize_stmt(ObExecContext &ctx,
|
||||
LOG_WARN("invalid argument", K(ret), KP(ctx.get_stmt_factory()->get_query_ctx()));
|
||||
} else {
|
||||
resolver_ctx.query_ctx_ = ctx.get_stmt_factory()->get_query_ctx();
|
||||
resolver_ctx.query_ctx_->question_marks_count_ = param_store.count();
|
||||
resolver_ctx.query_ctx_->set_questionmark_count(param_store.count());
|
||||
resolver_ctx.query_ctx_->sql_schema_guard_.set_schema_guard(ctx.get_sql_ctx()->schema_guard_);
|
||||
ObResolver resolver(resolver_ctx);
|
||||
ObStmt *astmt = NULL;
|
||||
|
@ -2254,43 +2254,30 @@ bool ObRelationalExprOperator::can_cmp_without_cast(ObExprResType type1,
|
||||
/*
|
||||
* Note that, the original motivation of this function is that,
|
||||
*
|
||||
* Provided that we have a = b and b = c in which a , b and c
|
||||
* are of metainfo meta1, meta2, meta3, respectively
|
||||
* Provided that we have a = b and b = c, can we deduce that a = c holds actually?
|
||||
*
|
||||
* So, can we deduce that a = c holds actually?
|
||||
* The return value of result is true represents equal comparison a = b is transitive, which means
|
||||
* for any a = b and b = c, if both of them are transitive, then we can always deduce a = c
|
||||
*
|
||||
* this func tells you this via result when and only when the ret is OB_SUCCESS
|
||||
* For example, we have the table definition like this
|
||||
* create table t1(c1 int, c2 tinyint, c3 int unsigned, c4 enum('a', 'b'), c5 enum('c', 'd'))
|
||||
* Then there is no need to add any implicit cast in c1 = c2, c1 = c3, c1 = c4, c1 = c5.
|
||||
* c1 = c2 and c1 = c3 is equal transitive, then we can deduce c2 = c3.
|
||||
* For comparison between enum types, they need cast to varchar implicitly, so we define comparison
|
||||
* between enum and int type class is not transitive.
|
||||
* Then we can not deduce c4 = c5 via c1 = c4 and c1 = c5, because they are not equal transitive.
|
||||
*/
|
||||
|
||||
int ObRelationalExprOperator::is_equivalent(const ObObjMeta &meta1,
|
||||
const ObObjMeta &meta2,
|
||||
const ObObjMeta &meta3,
|
||||
bool &result)
|
||||
int ObRelationalExprOperator::is_equal_transitive(const common::ObObjMeta &meta1,
|
||||
const common::ObObjMeta &meta2,
|
||||
bool &result)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
result = false;
|
||||
ObObjMeta equal_meta12;
|
||||
ObObjMeta equal_meta23;
|
||||
ObObjMeta equal_meta13;
|
||||
if (OB_FAIL(get_equal_meta(equal_meta12, meta1, meta2))) {
|
||||
ObObjMeta equal_meta;
|
||||
if (OB_FAIL(get_equal_meta(equal_meta, meta1, meta2))) {
|
||||
LOG_WARN("get equal meta failed", K(ret), K(meta1), K(meta2));
|
||||
} else if (OB_FAIL(get_equal_meta(equal_meta13, meta1, meta3))) {
|
||||
LOG_WARN("get equal meta failed", K(ret), K(meta1), K(meta3));
|
||||
} else if (OB_FAIL(get_equal_meta(equal_meta23, meta2, meta3))) {
|
||||
LOG_WARN("get equal meta failed", K(ret), K(meta2), K(meta3));
|
||||
} else if (OB_UNLIKELY(equal_meta12.get_type() == ObMaxType
|
||||
|| equal_meta13.get_type() == ObMaxType /* no need to check ObNullType here*/
|
||||
|| equal_meta23.get_type() == ObMaxType)) {
|
||||
/*result = false;*/
|
||||
} else if (equal_meta12.get_type() == equal_meta13.get_type()
|
||||
&& equal_meta13.get_type() == equal_meta23.get_type()) {
|
||||
if (OB_UNLIKELY(ob_is_string_or_lob_type(equal_meta12.get_type()))) {
|
||||
//all are string type
|
||||
result = equal_meta12.get_collation_type() == equal_meta13.get_collation_type()
|
||||
&& equal_meta13.get_collation_type() == equal_meta23.get_collation_type();
|
||||
} else {
|
||||
result = true;
|
||||
}
|
||||
} else {
|
||||
result = equal_meta.get_type() != ObMaxType;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -2307,8 +2294,11 @@ int ObRelationalExprOperator::get_equal_meta(ObObjMeta &meta,
|
||||
meta2.get_type()))) {
|
||||
LOG_WARN("get equal type failed", K(ret), K(meta1), K(meta2));
|
||||
} else if (ob_is_string_or_lob_type(type)) {
|
||||
ObObjMeta coll_types[2] = {meta1, meta2};
|
||||
ret = aggregate_charsets_for_comparison(meta, coll_types, 2, type_ctx);
|
||||
if (meta1.get_collation_type() != meta2.get_collation_type()) {
|
||||
type = ObMaxType;
|
||||
} else {
|
||||
meta.set_collation_type(meta1.get_collation_type());
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
meta.set_type(type);
|
||||
|
@ -1258,10 +1258,9 @@ public:
|
||||
bool is_null_safe,
|
||||
common::ObCmpOp cmp_op) const;
|
||||
|
||||
static int is_equivalent(const common::ObObjMeta &meta1,
|
||||
const common::ObObjMeta &meta2,
|
||||
const common::ObObjMeta &meta3,
|
||||
bool &result);
|
||||
static int is_equal_transitive(const common::ObObjMeta &meta1,
|
||||
const common::ObObjMeta &meta2,
|
||||
bool &result);
|
||||
int assign(const ObExprOperator &other);
|
||||
int set_cmp_func(const common::ObObjType type1,
|
||||
const common::ObObjType type2);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -365,6 +365,11 @@ public:
|
||||
// }
|
||||
return seed;
|
||||
}
|
||||
int hash(uint64_t &hash_val, uint64_t seed) const
|
||||
{
|
||||
hash_val = hash(seed);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
// others.
|
||||
INHERIT_TO_STRING_KV(N_META,
|
||||
ObObjMeta,
|
||||
|
@ -118,10 +118,10 @@ int ObExprResultTypeUtil::get_relational_equal_type(ObObjType &type,
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_ERROR("the wrong type", K(type1), K(type2), K(ret));
|
||||
} else {
|
||||
// we donot have ORACLE_RELATIONAL_EQUAL_TYPE, just use ORACLE_RELATIONAL_CMP_TYPE instead.
|
||||
type = (lib::is_oracle_mode()
|
||||
? ORACLE_RELATIONAL_CMP_TYPE[type1][type2]
|
||||
: RELATIONAL_EQUAL_TYPE[type1][type2]);
|
||||
const ObObjType *equal_type_array = lib::is_oracle_mode()
|
||||
? ORACLE_RELATIONAL_EQUAL_TYPE
|
||||
: RELATIONAL_EQUAL_TYPE;
|
||||
type = equal_type_array[type1] == equal_type_array[type2] ? equal_type_array[type1] : ObMaxType;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -1333,11 +1333,6 @@ int ObTableScanOp::build_bnlj_params()
|
||||
OZ(tsc_rtdef_.bnlj_params_.push_back(GroupRescanParamInfo(param_idx, group_param.gr_param_)));
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret) && tsc_rtdef_.bnlj_params_.empty()) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("batch param is empty in batch rescan", K(ret),
|
||||
K(MY_CTDEF.bnlj_param_idxs_), KPC(group_params_above));
|
||||
}
|
||||
if (OB_SUCC(ret) && (OB_ISNULL(fold_iter_))) {
|
||||
if (OB_FAIL(ObDASIterUtils::create_group_fold_iter(MY_CTDEF,
|
||||
tsc_rtdef_,
|
||||
|
@ -864,57 +864,60 @@ int ObSqlPlan::get_plan_other_info(PlanText &plan_text,
|
||||
LOG_WARN("unexpect null param", K(ret));
|
||||
} else {
|
||||
ObObjPrintParams print_params(query_ctx->get_timezone_info());
|
||||
BEGIN_BUF_PRINT
|
||||
ObPhyPlanType plan_type = plan->get_optimizer_context().get_phy_plan_type();
|
||||
if (OB_FAIL(BUF_PRINTF(" Plan Type:"))) {
|
||||
} else if (OB_FAIL(BUF_PRINTF(NEW_LINE))) {
|
||||
} else if (OB_FAIL(BUF_PRINTF(OUTPUT_PREFIX))) {
|
||||
} else if (OB_FAIL(BUF_PRINTF("%.*s",
|
||||
ob_plan_type_str(plan_type).length(),
|
||||
ob_plan_type_str(plan_type).ptr()))) {
|
||||
} else {
|
||||
ret = BUF_PRINTF(NEW_LINE);
|
||||
}
|
||||
|
||||
const ParamStore *params = NULL;
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_ISNULL(params = plan->get_optimizer_context().get_params())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
} else if (params->count() <= 0) {
|
||||
//do nothing
|
||||
} else if (OB_FAIL(BUF_PRINTF(NEW_LINE))) {
|
||||
} else if (OB_FAIL(BUF_PRINTF(" Parameters:"))) {
|
||||
} else if (OB_FAIL(BUF_PRINTF(NEW_LINE))) {
|
||||
} else { /* Do nothing */ }
|
||||
for (int64_t i = 0; OB_SUCC(ret) && NULL != params && i < params->count() && i < 100; i++) {
|
||||
if (OB_FAIL(BUF_PRINTF(OUTPUT_PREFIX))) {
|
||||
} else if (OB_FAIL(BUF_PRINTF(":%ld => ", i))) {
|
||||
ret = OB_E(EventTable::EN_PRINT_CONSTRAINTS_INFO) OB_SUCCESS;
|
||||
bool only_show_constraint = OB_SUCCESS != ret && EXPLAIN_UNINITIALIZED == plan_text.type_;
|
||||
ret = OB_SUCCESS;
|
||||
BEGIN_BUF_PRINT
|
||||
if (OB_SUCC(ret) && !only_show_constraint) {
|
||||
if (OB_FAIL(BUF_PRINTF(" Plan Type:"))) {
|
||||
} else if (OB_FAIL(BUF_PRINTF(NEW_LINE))) {
|
||||
} else if (OB_FAIL(BUF_PRINTF(OUTPUT_PREFIX))) {
|
||||
} else if (OB_FAIL(BUF_PRINTF("%.*s",
|
||||
ob_plan_type_str(plan_type).length(),
|
||||
ob_plan_type_str(plan_type).ptr()))) {
|
||||
} else {
|
||||
int64_t save_pos = pos;
|
||||
if (OB_FAIL(params->at(i).print_sql_literal(buf,
|
||||
buf_len,
|
||||
pos,
|
||||
print_params))) {
|
||||
//ignore size overflow error
|
||||
pos = save_pos;
|
||||
}
|
||||
if (OB_FAIL(BUF_PRINTF(NEW_LINE))) {
|
||||
} else { /* Do nothing */ }
|
||||
}
|
||||
}
|
||||
|
||||
const ObPlanNotes ¬es = plan->get_optimizer_context().get_plan_notes();
|
||||
if (notes.count() <= 0 || OB_FAIL(ret)) {
|
||||
} else if (OB_FAIL(BUF_PRINTF(NEW_LINE))) { /* Do nothing */
|
||||
} else if (OB_FAIL(BUF_PRINTF(" Note:"))) { /* Do nothing */
|
||||
} else if (OB_FAIL(BUF_PRINTF(NEW_LINE))) { /* Do nothing */
|
||||
}
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < notes.count(); i++) {
|
||||
if (OB_FAIL(BUF_PRINTF(OUTPUT_PREFIX))) {
|
||||
} else {
|
||||
pos += notes.at(i).to_string(buf + pos, buf_len - pos);
|
||||
ret = BUF_PRINTF(NEW_LINE);
|
||||
}
|
||||
const ParamStore *params = NULL;
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_ISNULL(params = plan->get_optimizer_context().get_params())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
} else if (params->count() <= 0) {
|
||||
//do nothing
|
||||
} else if (OB_FAIL(BUF_PRINTF(NEW_LINE))) {
|
||||
} else if (OB_FAIL(BUF_PRINTF(" Parameters:"))) {
|
||||
} else if (OB_FAIL(BUF_PRINTF(NEW_LINE))) {
|
||||
} else { /* Do nothing */ }
|
||||
for (int64_t i = 0; OB_SUCC(ret) && NULL != params && i < params->count() && i < 100; i++) {
|
||||
if (OB_FAIL(BUF_PRINTF(OUTPUT_PREFIX))) {
|
||||
} else if (OB_FAIL(BUF_PRINTF(":%ld => ", i))) {
|
||||
} else {
|
||||
int64_t save_pos = pos;
|
||||
if (OB_FAIL(params->at(i).print_sql_literal(buf,
|
||||
buf_len,
|
||||
pos,
|
||||
print_params))) {
|
||||
//ignore size overflow error
|
||||
pos = save_pos;
|
||||
}
|
||||
if (OB_FAIL(BUF_PRINTF(NEW_LINE))) {
|
||||
} else { /* Do nothing */ }
|
||||
}
|
||||
}
|
||||
const ObPlanNotes ¬es = plan->get_optimizer_context().get_plan_notes();
|
||||
if (notes.count() <= 0 || OB_FAIL(ret)) {
|
||||
} else if (OB_FAIL(BUF_PRINTF(NEW_LINE))) { /* Do nothing */
|
||||
} else if (OB_FAIL(BUF_PRINTF(" Note:"))) { /* Do nothing */
|
||||
} else if (OB_FAIL(BUF_PRINTF(NEW_LINE))) { /* Do nothing */
|
||||
}
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < notes.count(); i++) {
|
||||
if (OB_FAIL(BUF_PRINTF(OUTPUT_PREFIX))) {
|
||||
} else {
|
||||
pos += notes.at(i).to_string(buf + pos, buf_len - pos);
|
||||
ret = BUF_PRINTF(NEW_LINE);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_FAIL(get_constraint_info(buf, buf_len, pos, *query_ctx))) {
|
||||
@ -1100,6 +1103,19 @@ int ObSqlPlan::format_sql_plan(ObIArray<ObSqlPlanItem*> &sql_plan_infos,
|
||||
} else if (OB_FAIL(format_plan_output(sql_plan_infos, plan_text))) {
|
||||
LOG_WARN("failed to print plan output", K(ret));
|
||||
}
|
||||
} else if (EXPLAIN_UNINITIALIZED == type) {
|
||||
if (OB_FAIL(format_plan_table(sql_plan_infos, option, plan_text))) {
|
||||
LOG_WARN("failed to print plan", K(ret));
|
||||
} else if (OB_FAIL(format_plan_output(sql_plan_infos, plan_text))) {
|
||||
LOG_WARN("failed to print plan output", K(ret));
|
||||
} else {
|
||||
ret = OB_E(EventTable::EN_PRINT_CONSTRAINTS_INFO) OB_SUCCESS;
|
||||
bool only_show_constraint = OB_SUCCESS != ret;
|
||||
ret = OB_SUCCESS;
|
||||
if (only_show_constraint && OB_FAIL(format_other_info(sql_plan_infos, plan_text))) {
|
||||
LOG_WARN("failed to print other info", K(ret));
|
||||
}
|
||||
}
|
||||
} else if (EXPLAIN_OUTLINE == type) {
|
||||
if (OB_FAIL(format_plan_table(sql_plan_infos, option, plan_text))) {
|
||||
LOG_WARN("failed to print plan", K(ret));
|
||||
|
@ -682,8 +682,8 @@ int ObOptimizerTraceImpl::append(const JoinPath* join_path)
|
||||
new_line();
|
||||
append("tables:", join_path->right_path_->parent_);
|
||||
new_line();
|
||||
new_line();
|
||||
append_ptr(join_path->right_path_);
|
||||
new_line();
|
||||
append("cost:", join_path->right_path_->cost_, ",card:", join_path->right_path_->parent_->get_output_rows(),
|
||||
",width:", join_path->right_path_->parent_->get_output_row_size());
|
||||
new_line();
|
||||
@ -1082,6 +1082,8 @@ int ObOptimizerTraceImpl::trace_static(const ObDMLStmt *stmt, OptTableMetas &tab
|
||||
LOG_WARN("failed to append msg", K(ret));
|
||||
} else if (OB_FAIL(append("rows:",
|
||||
table_meta->get_rows(),
|
||||
"base rows:",
|
||||
table_meta->get_base_rows(),
|
||||
"statis type:",
|
||||
table_meta->use_default_stat() ? "DEFAULT" : "OPTIMIZER",
|
||||
"version:",
|
||||
@ -1110,6 +1112,10 @@ int ObOptimizerTraceImpl::trace_static(const ObDMLStmt *stmt, OptTableMetas &tab
|
||||
LOG_WARN("failed to append msg", K(ret));
|
||||
} else if (OB_FAIL(new_line())) {
|
||||
LOG_WARN("failed to append msg", K(ret));
|
||||
} else if (OB_FAIL(append("BASE NDV:", col_meta->get_base_ndv()))) {
|
||||
LOG_WARN("failed to append msg", K(ret));
|
||||
} else if (OB_FAIL(new_line())) {
|
||||
LOG_WARN("failed to append msg", K(ret));
|
||||
} else if (OB_FAIL(append("Null:", col_meta->get_num_null()))) {
|
||||
LOG_WARN("failed to append msg", K(ret));
|
||||
} else if (OB_FAIL(new_line())) {
|
||||
|
@ -3023,10 +3023,10 @@ int ObSql::generate_stmt(ParseResult &parse_result,
|
||||
if (OB_SUCC(ret)) {
|
||||
// set # of question marks
|
||||
if (context.is_prepare_protocol_ && !context.is_prepare_stage_) {
|
||||
resolver_ctx.query_ctx_->question_marks_count_ = plan_ctx->get_param_store().count();
|
||||
resolver_ctx.query_ctx_->set_questionmark_count(plan_ctx->get_param_store().count());
|
||||
LOG_DEBUG("question mark size is ", K(plan_ctx->get_param_store()));
|
||||
} else {
|
||||
resolver_ctx.query_ctx_->question_marks_count_ = static_cast<int64_t> (parse_result.question_mark_ctx_.count_);
|
||||
resolver_ctx.query_ctx_->set_questionmark_count(static_cast<int64_t>(parse_result.question_mark_ctx_.count_));
|
||||
LOG_DEBUG("question mark size is ", K(parse_result.question_mark_ctx_.count_));
|
||||
}
|
||||
|
||||
@ -4420,6 +4420,8 @@ int ObSql::parser_and_check(const ObString &outlined_stmt,
|
||||
ObPhysicalPlanCtx *pctx = exec_ctx.get_physical_plan_ctx();
|
||||
bool is_stack_overflow = false;
|
||||
bool is_show_variables = false;
|
||||
bool is_explain_parameterize = false;
|
||||
stmt::StmtType stmt_type = stmt::T_NONE;
|
||||
if (OB_ISNULL(session)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("session is null", K(ret));
|
||||
@ -4530,6 +4532,17 @@ int ObSql::parser_and_check(const ObString &outlined_stmt,
|
||||
}
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret) && stmt::T_EXPLAIN == stmt_type) {
|
||||
#ifndef OB_BUILD_SPM
|
||||
if (OB_SQL_PC_NOT_EXIST == get_plan_err) {
|
||||
#else
|
||||
if (OB_SQL_PC_NOT_EXIST == get_plan_err || pc_ctx.sql_ctx_.spm_ctx_.is_retry_for_spm_) {
|
||||
#endif
|
||||
is_explain_parameterize = true;
|
||||
} else {
|
||||
is_explain_parameterize = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4567,10 +4580,11 @@ int ObSql::parser_and_check(const ObString &outlined_stmt,
|
||||
//对于create outline限流语句,可能会带有问题。我们需要对?做特殊处理,
|
||||
//所以也需要经过transform_systax_tree
|
||||
bool flag = false;
|
||||
if ((add_plan_to_pc && !is_show_variables)
|
||||
|| ((T_CREATE_OUTLINE == parse_result.result_tree_->children_[0]->type_
|
||||
|| T_ALTER_OUTLINE == parse_result.result_tree_->children_[0]->type_)
|
||||
&& (INT64_MAX != parse_result.result_tree_->children_[0]->value_))) {
|
||||
if ((add_plan_to_pc && !is_show_variables) ||
|
||||
is_explain_parameterize ||
|
||||
((T_CREATE_OUTLINE == parse_result.result_tree_->children_[0]->type_ ||
|
||||
T_ALTER_OUTLINE == parse_result.result_tree_->children_[0]->type_) &&
|
||||
(INT64_MAX != parse_result.result_tree_->children_[0]->value_))) {
|
||||
flag = true;
|
||||
if (T_CREATE_OUTLINE == parse_result.result_tree_->children_[0]->type_) {
|
||||
if (1 != parse_result.result_tree_->children_[0]->children_[2]->value_) {
|
||||
@ -5232,9 +5246,10 @@ OB_NOINLINE int ObSql::handle_physical_plan(const ObString &trimed_stmt,
|
||||
(void) ObSpmController::deny_new_plan_as_baseline(spm_ctx);
|
||||
}
|
||||
} else if (plan_added && ObSpmCacheCtx::SpmStat::STAT_ADD_BASELINE_PLAN == spm_ctx.spm_stat_) {
|
||||
if (nullptr != spm_ctx.baseline_guard_.get_cache_obj() &&
|
||||
static_cast<ObPlanBaselineItem*>(spm_ctx.baseline_guard_.get_cache_obj())->get_fixed()) {
|
||||
// fixed baseline plan, use is directly
|
||||
if ((nullptr != spm_ctx.baseline_guard_.get_cache_obj() &&
|
||||
static_cast<ObPlanBaselineItem*>(spm_ctx.baseline_guard_.get_cache_obj())->get_fixed()) ||
|
||||
SPM_MODE_BASELINE_FIRST == spm_ctx.spm_mode_) {
|
||||
// fixed baseline plan or baseline first mode, use is directly
|
||||
} else {
|
||||
spm_ctx.spm_force_disable_ = true;
|
||||
spm_ctx.spm_stat_ = ObSpmCacheCtx::STAT_FIRST_EXECUTE_PLAN;
|
||||
|
@ -778,7 +778,8 @@ public:
|
||||
optimizer_features_enable_version_(0),
|
||||
udf_flag_(0),
|
||||
has_dblink_(false),
|
||||
injected_random_status_(false)
|
||||
injected_random_status_(false),
|
||||
ori_question_marks_count_(0)
|
||||
{
|
||||
}
|
||||
TO_STRING_KV(N_PARAM_NUM, question_marks_count_,
|
||||
@ -822,6 +823,7 @@ public:
|
||||
root_stmt_ = NULL;
|
||||
udf_flag_ = 0;
|
||||
optimizer_features_enable_version_ = 0;
|
||||
ori_question_marks_count_ = 0;
|
||||
}
|
||||
|
||||
int64_t get_new_stmt_id() { return stmt_count_++; }
|
||||
@ -862,7 +864,10 @@ public:
|
||||
bool check_opt_compat_version(uint64_t v1, uint64_t v2) const {
|
||||
return optimizer_features_enable_version_ >= v1 && optimizer_features_enable_version_ < v2;
|
||||
}
|
||||
|
||||
void set_questionmark_count(int64_t count) {
|
||||
ori_question_marks_count_ = count;
|
||||
question_marks_count_ = count;
|
||||
};
|
||||
|
||||
|
||||
public:
|
||||
@ -930,6 +935,7 @@ public:
|
||||
bool has_dblink_;
|
||||
bool injected_random_status_;
|
||||
ObRandom rand_gen_;
|
||||
int64_t ori_question_marks_count_;
|
||||
};
|
||||
|
||||
template<typename... Args>
|
||||
|
@ -762,6 +762,10 @@ static int16_t get_type_fixed_length(ObObjType type) {
|
||||
return len;
|
||||
}
|
||||
|
||||
#define SPM_MODE_DISABLE 0
|
||||
#define SPM_MODE_ONLINE_EVOLVE 1
|
||||
#define SPM_MODE_BASELINE_FIRST 2
|
||||
|
||||
} // namespace sql
|
||||
} // namespace oceanbase
|
||||
#endif /* OCEANBASE_SQL_OB_SQL_DEFINE_H_ */
|
||||
|
@ -354,7 +354,7 @@ int ObAccessPathEstimation::choose_best_est_method(ObOptimizerContext &ctx,
|
||||
ObSelEstimator *estimator = NULL;
|
||||
if (OB_FAIL(factory.create_estimator(*sel_ctx, filter, estimator))) {
|
||||
LOG_WARN("failed to create estimator", KPC(filter));
|
||||
} else if (estimator->tend_to_use_ds()) {
|
||||
} else if (estimator->is_complex_filter_qual()) {
|
||||
is_complex_scene = true;
|
||||
// path which contains complex filters is complex
|
||||
LOG_PRINT_EXPR(TRACE, "Try to use dynamic sampling because of complex filter:", filter);
|
||||
@ -2505,6 +2505,7 @@ int ObAccessPathEstimation::update_table_stat_info_by_dynamic_sampling(AccessPat
|
||||
LOG_WARN("failed to fill ds col stat", K(ret));
|
||||
} else {
|
||||
table_meta->set_rows(row_count);
|
||||
table_meta->set_base_rows(row_count);
|
||||
table_meta->set_use_ds_stat();
|
||||
}
|
||||
}
|
||||
@ -2524,6 +2525,7 @@ int ObAccessPathEstimation::update_table_stat_info_by_default(AccessPath *path)
|
||||
OptTableMeta *table_meta = table_metas.get_table_meta_by_table_id(path->table_id_);
|
||||
if (OB_NOT_NULL(table_meta)) {
|
||||
table_meta->set_rows(path->get_output_row_count());
|
||||
table_meta->set_base_rows(path->get_output_row_count());
|
||||
for (int64_t i = 0; i < table_meta->get_column_metas().count(); ++i) {
|
||||
table_meta->get_column_metas().at(i).set_default_meta(path->get_output_row_count());
|
||||
}
|
||||
@ -2666,6 +2668,7 @@ int ObAccessPathEstimation::update_column_metas_by_ds_col_stat(const int64_t row
|
||||
if (!found_it) {
|
||||
col_metas.at(i).set_ndv(rowcount);
|
||||
}
|
||||
col_metas.at(i).set_base_ndv(col_metas.at(i).get_ndv());
|
||||
}
|
||||
LOG_TRACE("update column metas by ds col stat", K(ds_col_stats), K(col_metas), K(rowcount));
|
||||
return ret;
|
||||
|
1015
src/sql/optimizer/ob_join_order.cpp
Normal file → Executable file
1015
src/sql/optimizer/ob_join_order.cpp
Normal file → Executable file
File diff suppressed because it is too large
Load Diff
97
src/sql/optimizer/ob_join_order.h
Normal file → Executable file
97
src/sql/optimizer/ob_join_order.h
Normal file → Executable file
@ -232,36 +232,47 @@ struct EstimateCostInfo {
|
||||
:join_filter_infos_(),
|
||||
need_row_count_(-1), //no need to refine row count
|
||||
need_parallel_(ObGlobalHint::UNSET_PARALLEL), //no need to refine parallel
|
||||
need_batch_rescan_(false),
|
||||
rescan_left_server_list_(NULL),
|
||||
override_(false) {}
|
||||
|
||||
void reset() {
|
||||
join_filter_infos_.reuse();
|
||||
need_row_count_ = -1;
|
||||
need_parallel_ = ObGlobalHint::UNSET_PARALLEL;
|
||||
need_batch_rescan_ = false;
|
||||
rescan_left_server_list_ = NULL;
|
||||
override_ = false;
|
||||
}
|
||||
int assign(const EstimateCostInfo& other) {
|
||||
need_row_count_ = other.need_row_count_;
|
||||
need_parallel_ = other.need_parallel_;
|
||||
need_batch_rescan_ = other.need_batch_rescan_;
|
||||
rescan_left_server_list_ = other.rescan_left_server_list_;
|
||||
override_ = other.override_;
|
||||
return join_filter_infos_.assign(other.join_filter_infos_);
|
||||
}
|
||||
bool need_re_est(int64_t cur_parallel, double cur_row_count) const {
|
||||
return override_ || !join_filter_infos_.empty()
|
||||
|| (ObGlobalHint::UNSET_PARALLEL != need_parallel_ && need_parallel_ != cur_parallel)
|
||||
|| (need_row_count_ >= 0 && need_row_count_ < cur_row_count);
|
||||
|| (need_row_count_ >= 0 && need_row_count_ < cur_row_count)
|
||||
|| (need_batch_rescan_ || NULL != rescan_left_server_list_);
|
||||
}
|
||||
|
||||
TO_STRING_KV(
|
||||
K_(join_filter_infos),
|
||||
K_(need_row_count),
|
||||
K_(need_parallel),
|
||||
K_(need_batch_rescan),
|
||||
K_(rescan_left_server_list),
|
||||
K_(override)
|
||||
);
|
||||
|
||||
ObSEArray<JoinFilterInfo, 4> join_filter_infos_;
|
||||
double need_row_count_;
|
||||
int64_t need_parallel_;
|
||||
bool need_batch_rescan_;
|
||||
const common::ObIArray<common::ObAddr> *rescan_left_server_list_;
|
||||
bool override_;
|
||||
};
|
||||
|
||||
@ -540,6 +551,8 @@ struct EstimateCostInfo {
|
||||
use_skip_scan_(OptSkipScanState::SS_UNSET),
|
||||
use_column_store_(false),
|
||||
is_valid_inner_path_(false),
|
||||
can_batch_rescan_(false),
|
||||
can_das_dynamic_part_pruning_(-1),
|
||||
is_index_merge_(false),
|
||||
is_ror_(false)
|
||||
{
|
||||
@ -595,6 +608,7 @@ struct EstimateCostInfo {
|
||||
ObCostTableScanInfo &est_cost_info,
|
||||
const SampleInfo &sample_info,
|
||||
const ObOptimizerContext &opt_ctx,
|
||||
const bool can_batch_rescan,
|
||||
double &card,
|
||||
double &cost);
|
||||
int check_adj_index_cost_valid(double &stats_phy_query_range_row_count,
|
||||
@ -622,6 +636,16 @@ struct EstimateCostInfo {
|
||||
return 1 == est_cost_info_.ranges_.count() && est_cost_info_.ranges_.at(0).is_false_range();
|
||||
}
|
||||
|
||||
int compute_access_path_batch_rescan();
|
||||
bool is_rescan_path() const { return est_cost_info_.is_rescan_; }
|
||||
int compute_is_das_dynamic_part_pruning(const EqualSets &equal_sets,
|
||||
const ObIArray<ObRawExpr*> &src_keys,
|
||||
const ObIArray<ObRawExpr*> &target_keys);
|
||||
bool can_das_dynamic_part_pruning() const { return can_das_dynamic_part_pruning_ > 0; }
|
||||
int64_t get_part_cnt_before_das_dynamic_part_pruning() const {
|
||||
return can_das_dynamic_part_pruning() && NULL != table_partition_info_
|
||||
? table_partition_info_->get_phy_tbl_location_info().get_partition_cnt() : 1;
|
||||
}
|
||||
TO_STRING_KV(K_(table_id),
|
||||
K_(ref_table_id),
|
||||
K_(index_id),
|
||||
@ -640,6 +664,8 @@ struct EstimateCostInfo {
|
||||
K_(use_skip_scan),
|
||||
K_(use_column_store),
|
||||
K_(is_valid_inner_path),
|
||||
K_(can_batch_rescan),
|
||||
K_(can_das_dynamic_part_pruning),
|
||||
K_(is_index_merge),
|
||||
K_(is_ror));
|
||||
public:
|
||||
@ -666,6 +692,8 @@ struct EstimateCostInfo {
|
||||
bool use_column_store_;
|
||||
// mark this access path is inner path and contribute query range
|
||||
bool is_valid_inner_path_;
|
||||
bool can_batch_rescan_;
|
||||
int64_t can_das_dynamic_part_pruning_;
|
||||
bool is_index_merge_; // whether used for index merge
|
||||
bool is_ror_; // indicate whether result from index table scan is ordered by primary key
|
||||
private:
|
||||
@ -775,7 +803,8 @@ struct EstimateCostInfo {
|
||||
has_none_equal_join_(false),
|
||||
can_use_batch_nlj_(false),
|
||||
is_naaj_(false),
|
||||
is_sna_(false)
|
||||
is_sna_(false),
|
||||
join_output_rows_(-1.0)
|
||||
{
|
||||
}
|
||||
|
||||
@ -812,7 +841,8 @@ struct EstimateCostInfo {
|
||||
can_use_batch_nlj_(false),
|
||||
is_naaj_(false),
|
||||
is_sna_(false),
|
||||
inherit_sharding_index_(-1)
|
||||
inherit_sharding_index_(-1),
|
||||
join_output_rows_(-1.0)
|
||||
{
|
||||
}
|
||||
virtual ~JoinPath() {}
|
||||
@ -825,7 +855,6 @@ struct EstimateCostInfo {
|
||||
EstimateCostInfo &left_param,
|
||||
EstimateCostInfo &right_param,
|
||||
bool re_est_for_op);
|
||||
int try_set_batch_nlj_for_right_access_path(bool enable);
|
||||
int re_estimate_rows(ObIArray<JoinFilterInfo> &pushdown_join_filter_infos,
|
||||
double left_output_rows,
|
||||
double right_output_rows,
|
||||
@ -988,6 +1017,10 @@ struct EstimateCostInfo {
|
||||
int64_t &available_parallel,
|
||||
int64_t &server_cnt,
|
||||
ObIArray<common::ObAddr> &server_list);
|
||||
inline bool is_nlj_with_param_down() const
|
||||
{ return NULL != right_path_ && right_path_->is_inner_path() && !right_path_->nl_params_.empty(); }
|
||||
int check_right_is_local_scan(bool &is_local_scan) const;
|
||||
int pre_check_nlj_can_px_batch_rescan(bool &can_px_batch_rescan) const;
|
||||
private:
|
||||
int compute_hash_hash_sharding_info();
|
||||
int compute_join_path_ordering();
|
||||
@ -996,9 +1029,11 @@ struct EstimateCostInfo {
|
||||
int compute_join_path_plan_type();
|
||||
int compute_join_path_parallel_and_server_info();
|
||||
int re_adjust_sharding_ordering_info();
|
||||
int can_use_batch_nlj(bool &use_batch_nlj);
|
||||
int can_use_batch_nlj(ObLogPlan *plan, const AccessPath *access_path, bool &use_batch_nlj);
|
||||
int can_use_das_batch_nlj(ObLogicalOperator* root, bool &use_batch_nlj);
|
||||
int compute_nlj_batch_rescan();
|
||||
int check_right_has_gi_or_exchange(bool &right_has_gi_or_exchange);
|
||||
int pre_check_can_px_batch_rescan(bool &find_nested_rescan,
|
||||
bool &find_rescan_px,
|
||||
bool nested) const;
|
||||
public:
|
||||
TO_STRING_KV(K_(join_algo),
|
||||
K_(join_dist_algo),
|
||||
@ -1020,7 +1055,8 @@ struct EstimateCostInfo {
|
||||
K_(can_use_batch_nlj),
|
||||
K_(is_naaj),
|
||||
K_(is_sna),
|
||||
K_(inherit_sharding_index));
|
||||
K_(inherit_sharding_index),
|
||||
K_(join_output_rows));
|
||||
public:
|
||||
const Path *left_path_;
|
||||
const Path *right_path_;
|
||||
@ -1052,6 +1088,11 @@ struct EstimateCostInfo {
|
||||
bool is_sna_; // is single null aware anti join
|
||||
//Used to indicate which child node the current sharding inherits from
|
||||
int64_t inherit_sharding_index_;
|
||||
/**
|
||||
* estimated rowcount under the current left and right join order trees,
|
||||
* might be different with the rowcount of parent_ join order
|
||||
*/
|
||||
double join_output_rows_;
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(JoinPath);
|
||||
};
|
||||
@ -1240,16 +1281,19 @@ struct InnerPathInfo {
|
||||
join_conditions_(),
|
||||
inner_paths_(),
|
||||
table_opt_info_(),
|
||||
force_inner_nl_(false) {}
|
||||
force_inner_nl_(false),
|
||||
join_type_(UNKNOWN_JOIN) {}
|
||||
virtual ~InnerPathInfo() {}
|
||||
TO_STRING_KV(K_(join_conditions),
|
||||
K_(inner_paths),
|
||||
K_(force_inner_nl));
|
||||
K_(force_inner_nl),
|
||||
K_(join_type));
|
||||
|
||||
common::ObSEArray<ObRawExpr*, 8, common::ModulePageAllocator, true> join_conditions_;
|
||||
common::ObSEArray<Path *, 8, common::ModulePageAllocator, true> inner_paths_;
|
||||
BaseTableOptInfo table_opt_info_;
|
||||
bool force_inner_nl_; //force generation of inner path, ignoring range check
|
||||
ObJoinType join_type_;
|
||||
};
|
||||
typedef common::ObSEArray<InnerPathInfo, 8, common::ModulePageAllocator, true> InnerPathInfos;
|
||||
|
||||
@ -1289,6 +1333,7 @@ struct NullAwareAntiJoinInfo {
|
||||
PathHelper()
|
||||
: is_inner_path_(false),
|
||||
force_inner_nl_(false),
|
||||
is_semi_anti_join_(false),
|
||||
child_stmt_(NULL),
|
||||
pushdown_filters_(),
|
||||
filters_(),
|
||||
@ -1300,6 +1345,7 @@ struct NullAwareAntiJoinInfo {
|
||||
|
||||
bool is_inner_path_;
|
||||
bool force_inner_nl_;
|
||||
bool is_semi_anti_join_;
|
||||
ObSelectStmt *child_stmt_;
|
||||
// when generate inner access path, save all pushdown filters
|
||||
// when generate subquery path, save all pushdown filters after rename
|
||||
@ -1350,7 +1396,6 @@ struct NullAwareAntiJoinInfo {
|
||||
output_table_set_(),
|
||||
output_rows_(-1.0),
|
||||
output_row_size_(-1.0),
|
||||
anti_or_semi_match_sel_(1.0),
|
||||
table_partition_info_(NULL),
|
||||
sharding_info_(NULL),
|
||||
table_meta_info_(common::OB_INVALID_ID),
|
||||
@ -1369,7 +1414,8 @@ struct NullAwareAntiJoinInfo {
|
||||
not_null_columns_(),
|
||||
inner_path_infos_(),
|
||||
cnt_rownum_(false),
|
||||
total_path_num_(0)
|
||||
total_path_num_(0),
|
||||
current_join_output_rows_(-1.0)
|
||||
{
|
||||
}
|
||||
virtual ~ObJoinOrder();
|
||||
@ -1479,7 +1525,9 @@ struct NullAwareAntiJoinInfo {
|
||||
int compute_path_relationship(const Path &first_path,
|
||||
const Path &second_path,
|
||||
DominateRelation &relation);
|
||||
|
||||
int compute_join_path_relationship(const JoinPath &first_path,
|
||||
const JoinPath &second_path,
|
||||
DominateRelation &relation);
|
||||
int compute_pipeline_relationship(const Path &first_path,
|
||||
const Path &second_path,
|
||||
DominateRelation &relation);
|
||||
@ -1670,13 +1718,22 @@ struct NullAwareAntiJoinInfo {
|
||||
ObSqlBitSet<> &used_column_ids);
|
||||
|
||||
int will_use_das(const uint64_t table_id,
|
||||
const uint64_t ref_id,
|
||||
const uint64_t index_id,
|
||||
const ObIndexInfoCache &index_info_cache,
|
||||
PathHelper &helper,
|
||||
bool &create_das_path,
|
||||
bool &create_basic_path);
|
||||
|
||||
int check_exec_force_use_das(const uint64_t table_id,
|
||||
bool &create_das_path,
|
||||
bool &create_basic_path);
|
||||
int check_opt_rule_use_das(const uint64_t table_id,
|
||||
const uint64_t index_id,
|
||||
const ObIndexInfoCache &index_info_cache,
|
||||
const ObIArray<ObRawExpr*> &filters,
|
||||
const bool is_rescan,
|
||||
bool &create_das_path,
|
||||
bool &create_basic_path);
|
||||
int will_use_skip_scan(const uint64_t table_id,
|
||||
const uint64_t ref_id,
|
||||
const uint64_t index_id,
|
||||
@ -2127,7 +2184,8 @@ struct NullAwareAntiJoinInfo {
|
||||
JoinFilterInfo &join_filter_info);
|
||||
|
||||
int fill_join_filter_info(JoinFilterInfo &join_filter_info);
|
||||
|
||||
int check_path_contain_filter(const Path* path, bool &contain);
|
||||
int check_path_contain_filter(const ObLogicalOperator* op, bool &contain);
|
||||
int check_normal_join_filter_valid(const Path& left_path,
|
||||
const Path& right_path,
|
||||
ObIArray<JoinFilterInfo> &join_filter_infos);
|
||||
@ -2144,6 +2202,7 @@ struct NullAwareAntiJoinInfo {
|
||||
int find_shuffle_join_filter(const Path& path, bool &find);
|
||||
|
||||
int check_partition_join_filter_valid(const DistAlgo join_dist_algo,
|
||||
const Path &right_path,
|
||||
ObIArray<JoinFilterInfo> &join_filter_infos);
|
||||
|
||||
int build_join_filter_part_expr(const int64_t ref_table_id,
|
||||
@ -2266,8 +2325,6 @@ struct NullAwareAntiJoinInfo {
|
||||
|
||||
int64_t get_diverse_path_count() const { return diverse_path_count_; }
|
||||
|
||||
inline double get_anti_or_semi_match_sel() const { return anti_or_semi_match_sel_; }
|
||||
|
||||
const ObFdItemSet &get_fd_item_set() const { return fd_item_set_; }
|
||||
|
||||
ObFdItemSet &get_fd_item_set() { return fd_item_set_; }
|
||||
@ -2320,9 +2377,6 @@ struct NullAwareAntiJoinInfo {
|
||||
ObCostTableScanInfo &est_cost_info,
|
||||
bool use_skip_scan);
|
||||
|
||||
int set_table_location_for_paths(ObIArray<AccessPath *> &access_paths,
|
||||
ObIndexInfoCache &index_info_cache);
|
||||
|
||||
int compute_table_location(const uint64_t table_id,
|
||||
const uint64_t ref_id,
|
||||
const bool is_global_index,
|
||||
@ -2575,6 +2629,7 @@ struct NullAwareAntiJoinInfo {
|
||||
ObJoinOrder &left_tree,
|
||||
ObJoinOrder &right_tree,
|
||||
const bool force_inner_nl,
|
||||
const ObJoinType join_type,
|
||||
ObIArray<Path *> &inner_paths);
|
||||
|
||||
int generate_inner_base_paths(const ObIArray<ObRawExpr *> &join_conditions,
|
||||
@ -2729,7 +2784,6 @@ struct NullAwareAntiJoinInfo {
|
||||
ObRelIds output_table_set_; //需要输出的table item下表, 经过semi join时只输出左枝
|
||||
double output_rows_;
|
||||
double output_row_size_;
|
||||
double anti_or_semi_match_sel_; //for anti/semi join
|
||||
ObTablePartitionInfo *table_partition_info_; // only for base table
|
||||
ObShardingInfo *sharding_info_; // only for base table and local index
|
||||
ObTableMetaInfo table_meta_info_; // only for base table
|
||||
@ -2752,6 +2806,7 @@ struct NullAwareAntiJoinInfo {
|
||||
bool cnt_rownum_;
|
||||
uint64_t total_path_num_;
|
||||
common::ObSEArray<double, 8, common::ModulePageAllocator, true> ambient_card_;
|
||||
double current_join_output_rows_; // 记录对当前连接树估计的输出行数
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObJoinOrder);
|
||||
};
|
||||
|
@ -118,7 +118,8 @@ int ObLogDistinct::get_distinct_output_exprs(ObIArray<ObRawExpr *> &output_exprs
|
||||
} else if (OB_FAIL(append_array_no_dup(candi_exprs, plan->get_orderby_exprs_for_width_est()))) {
|
||||
LOG_WARN("failed to add into output exprs", K(ret));
|
||||
} else if (OB_FAIL(ObRawExprUtils::extract_col_aggr_winfunc_exprs(candi_exprs,
|
||||
extracted_col_aggr_winfunc_exprs))) {
|
||||
extracted_col_aggr_winfunc_exprs,
|
||||
true))) {
|
||||
} else if (OB_FAIL(append_array_no_dup(output_exprs, extracted_col_aggr_winfunc_exprs))) {
|
||||
LOG_WARN("failed to add into output exprs", K(ret));
|
||||
} else {/*do nothing*/}
|
||||
|
@ -937,7 +937,7 @@ int ObLogExchange::find_need_drop_expr_idxs(ObLogicalOperator *op,
|
||||
if (OB_ISNULL(op->get_child(0))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected null op", K(ret));
|
||||
} else if (OB_FAIL(op->get_child(0)->check_has_exchange_below(left_has_exchange))) {
|
||||
} else if (OB_FAIL(op->get_child(0)->check_has_op_below(LOG_EXCHANGE, left_has_exchange))) {
|
||||
LOG_WARN("fail to check has exchange below");
|
||||
} else if (!left_has_exchange) {
|
||||
if (type == log_op_def::LOG_SUBPLAN_FILTER) {
|
||||
|
@ -101,7 +101,8 @@ public:
|
||||
const common::ObIArray<ObRawExpr *> &get_repart_func_exprs() const {return repartition_func_exprs_;}
|
||||
const common::ObIArray<ObExchangeInfo::HashExpr> &get_hash_dist_exprs() const {return hash_dist_exprs_;}
|
||||
const common::ObIArray<common::ObObj> *get_popular_values() const {return &popular_values_;}
|
||||
const ObRawExpr *get_calc_part_id_expr() { return calc_part_id_expr_; }
|
||||
const ObRawExpr *get_calc_part_id_expr() const { return calc_part_id_expr_; }
|
||||
ObRawExpr *get_calc_part_id_expr() { return calc_part_id_expr_; }
|
||||
ObRepartitionType get_repartition_type() const {return repartition_type_;}
|
||||
int64_t get_repartition_ref_table_id() const {return repartition_ref_table_id_;}
|
||||
int64_t get_repartition_table_id() const {return repartition_table_id_;}
|
||||
|
@ -245,12 +245,10 @@ int ObLogGroupBy::est_cost()
|
||||
} else if (OB_FAIL(inner_est_cost(get_parallel(),
|
||||
child_card,
|
||||
child_ndv,
|
||||
distinct_per_dop_,
|
||||
group_cost))) {
|
||||
LOG_WARN("failed to est group by cost", K(ret));
|
||||
} else {
|
||||
distinct_card_ = child_ndv;
|
||||
set_card(distinct_card_ * selectivity);
|
||||
set_card(child_ndv * selectivity);
|
||||
set_cost(child->get_cost() + group_cost);
|
||||
set_op_cost(group_cost);
|
||||
}
|
||||
@ -310,7 +308,6 @@ int ObLogGroupBy::do_re_est_cost(EstimateCostInfo ¶m, double &card, double &
|
||||
} else if (OB_FAIL(inner_est_cost(parallel,
|
||||
child_card,
|
||||
need_ndv,
|
||||
distinct_per_dop_,
|
||||
op_cost))) {
|
||||
LOG_WARN("failed to est distinct cost", K(ret));
|
||||
} else {
|
||||
@ -324,11 +321,11 @@ int ObLogGroupBy::do_re_est_cost(EstimateCostInfo ¶m, double &card, double &
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogGroupBy::inner_est_cost(const int64_t parallel, double child_card, double &child_ndv, double &per_dop_ndv, double &op_cost)
|
||||
int ObLogGroupBy::inner_est_cost(const int64_t parallel, double child_card, double &child_ndv, double &op_cost)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
double per_dop_card = 0.0;
|
||||
per_dop_ndv = 0.0;
|
||||
double per_dop_ndv = 0.0;
|
||||
common::ObSEArray<ObRawExpr *, 8> group_rollup_exprs;
|
||||
ObLogicalOperator *child = get_child(ObLogicalOperator::first_child);
|
||||
if (OB_ISNULL(get_plan()) ||
|
||||
@ -919,7 +916,7 @@ int ObLogGroupBy::compute_sharding_info()
|
||||
int ObLogGroupBy::get_card_without_filter(double &card)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
card = get_distinct_card();
|
||||
card = get_total_ndv();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -86,8 +86,6 @@ public:
|
||||
rollup_exprs_(),
|
||||
aggr_exprs_(),
|
||||
algo_(AGGREGATE_UNINITIALIZED),
|
||||
distinct_card_(0.0),
|
||||
distinct_per_dop_(0.0),
|
||||
from_pivot_(false),
|
||||
is_push_down_(false),
|
||||
is_partition_gi_(false),
|
||||
@ -155,7 +153,6 @@ public:
|
||||
int inner_est_cost(const int64_t parallel,
|
||||
double child_card,
|
||||
double &child_ndv,
|
||||
double &per_dop_ndv,
|
||||
double &op_cost);
|
||||
int get_child_est_info(const int64_t parallel, double &child_card, double &child_ndv, double &selectivity);
|
||||
int get_gby_output_exprs(ObIArray<ObRawExpr *> &output_exprs);
|
||||
@ -167,8 +164,6 @@ public:
|
||||
virtual int compute_equal_set() override;
|
||||
virtual int compute_fd_item_set() override;
|
||||
virtual int compute_op_ordering() override;
|
||||
double get_distinct_card() const { return distinct_card_; }
|
||||
void set_distinct_card(const double distinct_card) { distinct_card_ = distinct_card; }
|
||||
bool from_pivot() const { return from_pivot_; }
|
||||
void set_from_pivot(const bool value) { from_pivot_ = value; }
|
||||
int get_group_rollup_exprs(common::ObIArray<ObRawExpr *> &group_rollup_exprs) const;
|
||||
@ -241,7 +236,7 @@ public:
|
||||
void set_pushdown_scalar_aggr() { is_pushdown_scalar_aggr_ = true; }
|
||||
bool is_pushdown_scalar_aggr() { return is_pushdown_scalar_aggr_; }
|
||||
|
||||
VIRTUAL_TO_STRING_KV(K_(group_exprs), K_(rollup_exprs), K_(aggr_exprs), K_(algo), K_(distinct_card),
|
||||
VIRTUAL_TO_STRING_KV(K_(group_exprs), K_(rollup_exprs), K_(aggr_exprs), K_(algo),
|
||||
K_(is_push_down));
|
||||
virtual int get_card_without_filter(double &card) override;
|
||||
private:
|
||||
@ -258,9 +253,6 @@ private:
|
||||
common::ObSEArray<ObRawExpr *, 8, common::ModulePageAllocator, true> rollup_exprs_;
|
||||
common::ObSEArray<ObRawExpr *, 8, common::ModulePageAllocator, true> aggr_exprs_;
|
||||
AggregateAlgo algo_;
|
||||
// used for the execution engine to set hash bucket size
|
||||
double distinct_card_;
|
||||
double distinct_per_dop_;
|
||||
bool from_pivot_;
|
||||
bool is_push_down_;
|
||||
bool is_partition_gi_;
|
||||
|
@ -416,9 +416,9 @@ int ObLogJoin::do_re_est_cost(EstimateCostInfo ¶m, double &card, double &op_
|
||||
ObLogicalOperator *left_child = get_child(ObLogicalOperator::first_child);
|
||||
ObLogicalOperator *right_child = get_child(ObLogicalOperator::second_child);
|
||||
const int64_t parallel = param.need_parallel_;
|
||||
if (OB_ISNULL(left_child) || OB_ISNULL(right_child)) {
|
||||
if (OB_ISNULL(left_child) || OB_ISNULL(right_child) || OB_UNLIKELY(param.need_batch_rescan_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpect null join path", K(ret));
|
||||
LOG_WARN("unexpected params", K(ret), K(left_child), K(right_child), K(param));
|
||||
} else if (OB_ISNULL(join_path_)) {
|
||||
card = get_card();
|
||||
op_cost = get_op_cost();
|
||||
@ -432,14 +432,10 @@ int ObLogJoin::do_re_est_cost(EstimateCostInfo ¶m, double &card, double &op_
|
||||
left_output_rows,
|
||||
left_cost)))) {
|
||||
LOG_WARN("failed to re estimate cost", K(ret));
|
||||
} else if (OB_FAIL(join_path_->try_set_batch_nlj_for_right_access_path(true))) {
|
||||
LOG_WARN("failed to try set batch nlj for right access path", K(ret));
|
||||
} else if (OB_FAIL(SMART_CALL(right_child->re_est_cost(right_param,
|
||||
right_output_rows,
|
||||
right_cost)))) {
|
||||
LOG_WARN("failed to re estimate cost", K(ret));
|
||||
} else if (OB_FAIL(join_path_->try_set_batch_nlj_for_right_access_path(false))) {
|
||||
LOG_WARN("failed to try set batch nlj for right access path", K(ret));
|
||||
} else if (OB_FAIL(join_path_->re_estimate_rows(param.join_filter_infos_,
|
||||
left_output_rows,
|
||||
right_output_rows,
|
||||
@ -1277,195 +1273,6 @@ int ObLogJoin::allocate_startup_expr_post()
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogJoin::set_use_batch(ObLogicalOperator* root)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_ISNULL(root)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("invalid input", K(ret));
|
||||
} else if (root->is_table_scan()) {
|
||||
ObLogTableScan *ts = static_cast<ObLogTableScan*>(root);
|
||||
// dblink can not support batch nlj
|
||||
bool has_param = false;
|
||||
ObSEArray<int64_t, 1> idx_array;
|
||||
if (OB_FAIL(ts->extract_bnlj_param_idxs(idx_array))) {
|
||||
LOG_WARN("extract param indexes failed", KR(ret));
|
||||
}
|
||||
for (int64_t i = 0; OB_SUCC(ret) && !has_param && i < nl_params_.count(); i++) {
|
||||
int64_t param_idx = nl_params_.at(i)->get_param_index();
|
||||
for (int64_t j = 0; OB_SUCC(ret) && j < idx_array.count(); j++) {
|
||||
if (param_idx == idx_array.at(j)) {
|
||||
has_param = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
if ((ts->has_index_scan_filter() && ts->get_index_back() && ts->get_is_index_global()) ||
|
||||
ts->is_text_retrieval_scan()) {
|
||||
// For the global index lookup, if there is a pushdown filter when scanning the index,
|
||||
// batch cannot be used.
|
||||
ts->set_use_batch(false);
|
||||
} else {
|
||||
ts->set_use_batch(ts->use_batch() || (can_use_batch_nlj_ && has_param));
|
||||
}
|
||||
}
|
||||
} else if (root->get_num_of_child() == 1) {
|
||||
if(OB_FAIL(SMART_CALL(set_use_batch(root->get_child(first_child))))) {
|
||||
LOG_WARN("failed to check use batch nlj", K(ret));
|
||||
}
|
||||
} else if (log_op_def::LOG_SET == root->get_type()) {
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < root->get_num_of_child(); ++i) {
|
||||
ObLogicalOperator *child = root->get_child(i);
|
||||
if (OB_ISNULL(child)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("invalid child", K(ret));
|
||||
} else if (OB_FAIL(SMART_CALL(set_use_batch(child)))) {
|
||||
LOG_WARN("failed to check use batch nlj", K(ret));
|
||||
}
|
||||
}
|
||||
} else if (log_op_def::LOG_JOIN == root->get_type()) {
|
||||
ObLogJoin *join = NULL;
|
||||
ObLogicalOperator *left_child = NULL;
|
||||
ObLogicalOperator *rigtht_child = NULL;
|
||||
if (OB_ISNULL(join = static_cast<ObLogJoin *>(root))
|
||||
|| OB_ISNULL(left_child = join->get_child(0))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("invalid input", K(ret));
|
||||
} else if (OB_FAIL(SMART_CALL(set_use_batch(left_child)))) {
|
||||
LOG_WARN("failed to check use batch nlj", K(ret));
|
||||
} else if (!join->can_use_batch_nlj()) {
|
||||
// do nothing
|
||||
} else if (OB_ISNULL(rigtht_child = join->get_child(1))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("invalid child", K(ret));
|
||||
} else if (OB_FAIL(SMART_CALL(set_use_batch(rigtht_child)))) {
|
||||
LOG_WARN("failed to check use batch nlj", K(ret));
|
||||
}
|
||||
} else { /*do nothing*/ }
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogJoin::check_and_set_use_batch()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObSQLSessionInfo *session_info = NULL;
|
||||
ObLogPlan *plan = NULL;
|
||||
ObQueryCtx *query_ctx = NULL;
|
||||
if (OB_ISNULL(plan = get_plan())
|
||||
|| OB_ISNULL(session_info = plan->get_optimizer_context().get_session_info())
|
||||
|| OB_ISNULL(query_ctx = plan->get_optimizer_context().get_query_ctx())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected null", K(ret), K(plan), K(session_info), K(query_ctx));
|
||||
} else if (!can_use_batch_nlj_) {
|
||||
// do nothing
|
||||
} else if (OB_FALSE_IT(can_use_batch_nlj_ = plan->get_optimizer_context().get_nlj_batching_enabled())) {
|
||||
} else if (NESTED_LOOP_JOIN != get_join_algo()) {
|
||||
can_use_batch_nlj_ = false;
|
||||
}
|
||||
// check use batch
|
||||
if (OB_SUCC(ret) && can_use_batch_nlj_) {
|
||||
bool contains_invalid_startup = false;
|
||||
bool contains_limit = false;
|
||||
bool enable_group_rescan_test_mode = false;
|
||||
enable_group_rescan_test_mode = (OB_SUCCESS != (OB_E(EventTable::EN_DAS_GROUP_RESCAN_TEST_MODE) OB_SUCCESS));
|
||||
if (get_child(1)->get_type() == log_op_def::LOG_GRANULE_ITERATOR && !enable_group_rescan_test_mode) {
|
||||
can_use_batch_nlj_ = false;
|
||||
} else if (OB_FAIL(plan->contains_startup_with_exec_param(get_child(1),
|
||||
contains_invalid_startup))) {
|
||||
LOG_WARN("failed to check contains invalid startup", K(ret));
|
||||
} else if (contains_invalid_startup) {
|
||||
can_use_batch_nlj_ = false;
|
||||
} else if (OB_FAIL(plan->contains_limit_or_pushdown_limit(get_child(1), contains_limit))) {
|
||||
LOG_WARN("failed to check contains limit", K(ret));
|
||||
} else if (contains_limit) {
|
||||
can_use_batch_nlj_ = false;
|
||||
} else if (OB_FAIL(check_if_disable_batch(get_child(1), can_use_batch_nlj_))) {
|
||||
LOG_WARN("failed to check if disable batch", K(ret));
|
||||
} else if (can_use_batch_nlj_ && OB_FAIL(ObOptimizerUtil::check_ancestor_node_support_skip_scan(this, can_use_batch_nlj_))) {
|
||||
LOG_WARN("failed to check whether ancestor node support skip read", K(ret));
|
||||
}
|
||||
}
|
||||
// set use batch
|
||||
if (OB_SUCC(ret) && can_use_batch_nlj_) {
|
||||
if (OB_FAIL(set_use_batch(get_child(1)))) {
|
||||
LOG_WARN("failed to set use batch nlj", K(ret));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int ObLogJoin::check_if_disable_batch(ObLogicalOperator* root, bool &can_use_batch_nlj)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_ISNULL(root)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected null", K(ret));
|
||||
} else if (!can_use_batch_nlj) {
|
||||
// do nothing
|
||||
} else if (root->is_table_scan()) {
|
||||
ObLogTableScan *ts = NULL;
|
||||
ObLogPlan *plan = NULL;
|
||||
ObTablePartitionInfo *info = NULL;
|
||||
if (OB_ISNULL(ts = static_cast<ObLogTableScan *>(root)) ||
|
||||
OB_ISNULL(plan = get_plan()) ||
|
||||
OB_ISNULL(info = ts->get_table_partition_info())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("invalid input", K(ret));
|
||||
} else if (ts->has_index_scan_filter() && ts->get_index_back() && ts->get_is_index_global()) {
|
||||
// For the global index lookup, if there is a pushdown filter when scanning the index,
|
||||
// batch cannot be used.
|
||||
can_use_batch_nlj = false;
|
||||
} else if (ts->get_scan_direction() != default_asc_direction() && ts->get_scan_direction() != ObOrderDirection::UNORDERED) {
|
||||
can_use_batch_nlj = false;
|
||||
} else if (ts->use_index_merge()) {
|
||||
can_use_batch_nlj = false;
|
||||
} else {
|
||||
SMART_VAR(ObTablePartitionInfo, tmp_info) {
|
||||
ObTablePartitionInfo *tmp_info_ptr = &tmp_info;
|
||||
if (OB_FAIL(plan->gen_das_table_location_info(ts, tmp_info_ptr))) {
|
||||
LOG_WARN("failed to gen das table location info", K(ret));
|
||||
} else {
|
||||
if (tmp_info.get_table_location().use_das() &&
|
||||
tmp_info.get_table_location().get_has_dynamic_exec_param()) {
|
||||
// dynamic partition pruning, no need to check
|
||||
} else if (10 < info->get_phy_tbl_location_info().get_phy_part_loc_info_list().count()) {
|
||||
can_use_batch_nlj = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (1 == root->get_num_of_child()) {
|
||||
if (OB_FAIL(SMART_CALL(check_if_disable_batch(root->get_child(0), can_use_batch_nlj)))) {
|
||||
LOG_WARN("failed to check if disable batch", K(ret));
|
||||
}
|
||||
} else if (log_op_def::LOG_SET == root->get_type()) {
|
||||
ObLogSet *log_set = static_cast<ObLogSet *>(root);
|
||||
if (log_set->get_set_op() != ObSelectStmt::UNION) {
|
||||
if (GET_MIN_CLUSTER_VERSION() < CLUSTER_VERSION_4_3_1_0) {
|
||||
// if the min cluster version is less than 4.3.1.0, don't uses NLJ group-rescan because the old version don't adaptive group-rescan
|
||||
can_use_batch_nlj = false;
|
||||
LOG_TRACE("updrade stage don't support group-rescan if the min cluster version is less than 4.3.1.0 for distinct and except operator");
|
||||
}
|
||||
}
|
||||
for (int64_t i = 0; OB_SUCC(ret) && can_use_batch_nlj && i < root->get_num_of_child(); ++i) {
|
||||
ObLogicalOperator *child = root->get_child(i);
|
||||
if (OB_ISNULL(child)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("invalid child", K(ret));
|
||||
} else if (OB_FAIL(SMART_CALL(check_if_disable_batch(child, can_use_batch_nlj)))) {
|
||||
LOG_WARN("failed to check if disable batch", K(ret));
|
||||
}
|
||||
}
|
||||
} else if (log_op_def::LOG_JOIN == root->get_type()) {
|
||||
// multi level nlj use batch is disabled
|
||||
can_use_batch_nlj = false;
|
||||
} else {
|
||||
can_use_batch_nlj = false;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool ObLogJoin::is_my_exec_expr(const ObRawExpr *expr)
|
||||
{
|
||||
return ObOptimizerUtil::find_item(nl_params_, expr);
|
||||
|
@ -158,8 +158,6 @@ namespace sql
|
||||
|
||||
inline bool can_use_batch_nlj() const { return can_use_batch_nlj_; }
|
||||
void set_can_use_batch_nlj(bool can_use) { can_use_batch_nlj_ = can_use; }
|
||||
int check_and_set_use_batch();
|
||||
int check_if_disable_batch(ObLogicalOperator* root, bool &can_use_batch_nlj);
|
||||
void set_join_path(JoinPath *path) { join_path_ = path; }
|
||||
JoinPath *get_join_path() { return join_path_; }
|
||||
bool is_my_exec_expr(const ObRawExpr *expr);
|
||||
@ -185,7 +183,6 @@ namespace sql
|
||||
}
|
||||
|
||||
private:
|
||||
int set_use_batch(ObLogicalOperator* root);
|
||||
inline bool can_enable_gi_partition_pruning()
|
||||
{
|
||||
return (NESTED_LOOP_JOIN == join_algo_)
|
||||
|
@ -135,6 +135,8 @@ ObLogPlan::ObLogPlan(ObOptimizerContext &ctx, const ObDMLStmt *stmt)
|
||||
max_op_id_(OB_INVALID_ID),
|
||||
is_subplan_scan_(false),
|
||||
is_parent_set_distinct_(false),
|
||||
is_rescan_subplan_(false),
|
||||
disable_child_batch_rescan_(false),
|
||||
temp_table_info_(NULL),
|
||||
const_exprs_(),
|
||||
hash_dist_info_(),
|
||||
@ -296,8 +298,6 @@ int ObLogPlan::generate_join_orders()
|
||||
stmt->get_semi_infos(),
|
||||
quals))) {
|
||||
LOG_WARN("failed to distribute special quals", K(ret));
|
||||
} else if (OB_FAIL(collect_subq_pushdown_filter_table_relids(quals))) {
|
||||
LOG_WARN("failed to compute subplan das table ids", K(ret));
|
||||
} else if (OB_FAIL(generate_base_level_join_order(base_table_items,
|
||||
base_level))) {
|
||||
LOG_WARN("fail to generate base level join order", K(ret));
|
||||
@ -2410,6 +2410,7 @@ int ObLogPlan::inner_remove_redundancy_pred(ObIArray<ObRawExpr*> &join_pred,
|
||||
} else if (T_OP_EQ == cur_expr->get_expr_type() &&
|
||||
2 == cur_expr->get_param_count() &&
|
||||
cur_expr->get_param_expr(0) != cur_expr->get_param_expr(1)) {
|
||||
EqualSets tmp_equal_sets;
|
||||
if (OB_ISNULL(left_expr = cur_expr->get_param_expr(0)) ||
|
||||
OB_ISNULL(right_expr = cur_expr->get_param_expr(1))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
@ -2438,9 +2439,12 @@ int ObLogPlan::inner_remove_redundancy_pred(ObIArray<ObRawExpr*> &join_pred,
|
||||
// remove preds which is equation between two exprs in the same equal sets
|
||||
has_checked.at(i) = true;
|
||||
OPT_TRACE("remove redundancy join condition:", cur_expr);
|
||||
} else if (OB_FAIL(tmp_equal_sets.assign(equal_sets))) {
|
||||
LOG_WARN("failed to append fd equal set", K(ret));
|
||||
} else if (FALSE_IT(equal_sets.reuse())) {
|
||||
} else if (OB_FAIL(ObEqualAnalysis::compute_equal_set(&allocator_,
|
||||
cur_expr,
|
||||
equal_sets,
|
||||
tmp_equal_sets,
|
||||
equal_sets))) {
|
||||
LOG_WARN("failed to compute equal sets for inner join", K(ret));
|
||||
} else if (OB_FAIL(new_join_pred.push_back(cur_expr))) {
|
||||
@ -2476,9 +2480,13 @@ int ObLogPlan::generate_subplan_for_query_ref(ObQueryRefRawExpr *query_ref,
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
// check if sub plan has been generated
|
||||
subplan_info = NULL;
|
||||
const ObSelectStmt *subquery = NULL;
|
||||
ObLogPlan *logical_plan = NULL;
|
||||
ObOptimizerContext &opt_ctx = get_optimizer_context();
|
||||
bool has_ref_assign_user_var = false;
|
||||
SubPlanInfo *info = NULL;
|
||||
bool is_initplan = false;
|
||||
OPT_TRACE_TITLE("start generate subplan for subquery expr");
|
||||
OPT_TRACE_BEGIN_SECTION;
|
||||
if (OB_ISNULL(subquery = query_ref->get_ref_stmt())) {
|
||||
@ -2492,6 +2500,11 @@ int ObLogPlan::generate_subplan_for_query_ref(ObQueryRefRawExpr *query_ref,
|
||||
LOG_WARN("failed to create plan", K(ret), K(opt_ctx.get_query_ctx()->get_sql_stmt()));
|
||||
} else if (FALSE_IT(logical_plan->set_nonrecursive_plan_for_fake_cte(get_nonrecursive_plan_for_fake_cte()))) {
|
||||
// never reach
|
||||
} else if (OB_FAIL(subquery->has_ref_assign_user_var(has_ref_assign_user_var))) {
|
||||
LOG_WARN("faield to check stmt has assignment ref user var", K(ret));
|
||||
} else if (OB_FALSE_IT(is_initplan = !query_ref->has_exec_param() && !has_ref_assign_user_var)) {
|
||||
} else if (OB_FAIL(logical_plan->init_rescan_info_for_query_ref(*this, !is_initplan))) {
|
||||
LOG_WARN("failed to init rescan info", K(ret));
|
||||
} else if (OB_FAIL(logical_plan->add_exec_params_meta(query_ref->get_exec_params(),
|
||||
get_basic_table_metas(),
|
||||
get_selectivity_ctx()))) {
|
||||
@ -2502,29 +2515,22 @@ int ObLogPlan::generate_subplan_for_query_ref(ObQueryRefRawExpr *query_ref,
|
||||
logical_plan->get_update_table_metas(),
|
||||
logical_plan->get_selectivity_ctx()))) {
|
||||
LOG_WARN("failed to add expr meta", K(ret));
|
||||
} else if (OB_ISNULL(info = static_cast<SubPlanInfo *>(get_allocator().alloc(sizeof(SubPlanInfo))))) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_ERROR("failed to alloc semi info", K(ret));
|
||||
} else {
|
||||
SubPlanInfo *info = static_cast<SubPlanInfo *>(get_allocator().alloc(sizeof(SubPlanInfo)));
|
||||
bool has_ref_assign_user_var = false;
|
||||
if (OB_ISNULL(info)) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_ERROR("failed to alloc semi info", K(ret));
|
||||
} else if (OB_FAIL(subquery->has_ref_assign_user_var(has_ref_assign_user_var))) {
|
||||
LOG_WARN("faield to check stmt has assignment ref user var", K(ret));
|
||||
} else {
|
||||
/**
|
||||
* 作为initplan的条件:
|
||||
* 1. 不含上层变量,如果含上层变量会在本层当作Const
|
||||
* 2. 不含存在赋值操作的用户变量
|
||||
*/
|
||||
bool is_initplan = !query_ref->has_exec_param() && !has_ref_assign_user_var;
|
||||
info = new(info)SubPlanInfo(query_ref, logical_plan, is_initplan);
|
||||
if (OB_FAIL(add_subplan(info))) {
|
||||
LOG_WARN("failed to add sp params to rel", K(ret));
|
||||
} else {
|
||||
logical_plan->set_query_ref(query_ref);
|
||||
subplan_info = info;
|
||||
LOG_TRACE("succ to generate logical plan of sub-select");
|
||||
}
|
||||
info = new(info)SubPlanInfo(query_ref, logical_plan, is_initplan);
|
||||
if (OB_FAIL(add_subplan(info))) {
|
||||
LOG_WARN("failed to add sp params to rel", K(ret));
|
||||
} else {
|
||||
logical_plan->set_query_ref(query_ref);
|
||||
subplan_info = info;
|
||||
LOG_TRACE("succ to generate logical plan of sub-select");
|
||||
}
|
||||
|
||||
if (OB_FAIL(ret) && NULL != info) {
|
||||
@ -2539,6 +2545,29 @@ int ObLogPlan::generate_subplan_for_query_ref(ObQueryRefRawExpr *query_ref,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogPlan::init_rescan_info_for_query_ref(const ObLogPlan &parent_plan,
|
||||
const bool is_rescan_subquery)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
is_rescan_subplan_ = parent_plan.is_rescan_subplan_ || is_rescan_subquery;
|
||||
disable_child_batch_rescan_ = parent_plan.disable_child_batch_rescan_
|
||||
|| (is_rescan_subquery
|
||||
&& !get_optimizer_context().enable_experimental_batch_rescan());
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogPlan::init_rescan_info_for_subquery_paths(const ObLogPlan &parent_plan,
|
||||
const bool is_inner_path,
|
||||
const bool is_semi_anti_join_inner_path)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
is_rescan_subplan_ = parent_plan.is_rescan_subplan_ || is_inner_path;
|
||||
disable_child_batch_rescan_ = parent_plan.disable_child_batch_rescan_
|
||||
|| (is_semi_anti_join_inner_path
|
||||
&& !get_optimizer_context().enable_experimental_batch_rescan());
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogPlan::add_exec_params_meta(ObIArray<ObExecParamRawExpr *> &exec_params,
|
||||
const OptTableMetas &table_metas,
|
||||
const OptSelectivityCtx &ctx)
|
||||
@ -2957,10 +2986,10 @@ int ObLogPlan::allocate_access_path(AccessPath *ap,
|
||||
if (ap->est_cost_info_.table_filters_.count() > 0) {
|
||||
bool has_index_scan_filter = false;
|
||||
bool has_index_lookup_filter = false;
|
||||
if (OB_FAIL(get_has_global_index_filters(ap->filter_,
|
||||
scan->get_idx_columns(),
|
||||
has_index_scan_filter,
|
||||
has_index_lookup_filter))) {
|
||||
if (OB_FAIL(ObOptimizerUtil::get_has_global_index_filters(scan->get_filter_exprs(),
|
||||
scan->get_idx_columns(),
|
||||
has_index_scan_filter,
|
||||
has_index_lookup_filter))) {
|
||||
LOG_WARN("failed to get has global index filters", K(ret));
|
||||
} else {
|
||||
scan->set_has_index_scan_filter(has_index_scan_filter);
|
||||
@ -2977,39 +3006,6 @@ int ObLogPlan::allocate_access_path(AccessPath *ap,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogPlan::get_has_global_index_filters(const ObIArray<ObRawExpr*> &filter_exprs,
|
||||
const ObIArray<uint64_t> &index_columns,
|
||||
bool &has_index_scan_filter,
|
||||
bool &has_index_lookup_filter)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
has_index_scan_filter = false;
|
||||
has_index_lookup_filter = false;
|
||||
ObSEArray<bool, 4> filter_before_index_back;
|
||||
if (OB_FAIL(ObOptimizerUtil::check_filter_before_indexback(filter_exprs,
|
||||
index_columns,
|
||||
filter_before_index_back))) {
|
||||
LOG_WARN("Failed to check filter before index back", K(ret));
|
||||
} else if (OB_UNLIKELY(filter_before_index_back.count() != filter_exprs.count())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unequal array size", K(filter_before_index_back.count()),
|
||||
K(filter_exprs.count()), K(ret));
|
||||
} else {
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < filter_before_index_back.count(); i++) {
|
||||
if (OB_ISNULL(filter_exprs.at(i))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("null expr", K(ret));
|
||||
} else if (filter_before_index_back.at(i) &&
|
||||
!filter_exprs.at(i)->has_flag(CNT_SUB_QUERY)) {
|
||||
has_index_scan_filter = true;
|
||||
} else {
|
||||
has_index_lookup_filter = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogPlan::store_index_column_ids(
|
||||
ObSqlSchemaGuard &schema_guard,
|
||||
ObLogTableScan &scan,
|
||||
@ -5196,6 +5192,7 @@ int ObLogPlan::try_to_generate_pullup_aggr(ObAggFunRawExpr *old_aggr,
|
||||
} else if (OB_FAIL(ObOptimizerUtil::generate_pullup_aggr_expr(
|
||||
get_optimizer_context().get_expr_factory(),
|
||||
get_optimizer_context().get_session_info(),
|
||||
static_cast<ObAggFunRawExpr *>(group_replaced_exprs_.at(i).second)->get_expr_type(),
|
||||
static_cast<ObAggFunRawExpr *>(group_replaced_exprs_.at(i).second),
|
||||
new_aggr))) {
|
||||
LOG_WARN("failed to generate pullup aggr expr", K(ret));
|
||||
@ -5615,18 +5612,8 @@ int ObLogPlan::init_distinct_helper(const ObIArray<ObRawExpr*> &distinct_exprs,
|
||||
} else if (OB_FAIL(check_storage_distinct_pushdown(distinct_exprs,
|
||||
distinct_helper.can_storage_pushdown_))) {
|
||||
LOG_WARN("failed to check can storage distinct pushdown", K(ret));
|
||||
} else if (get_log_plan_hint().no_pushdown_distinct()) {
|
||||
OPT_TRACE("hint disable pushdown distinct");
|
||||
} else if (OB_ISNULL(session_info = get_optimizer_context().get_session_info())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected null", K(session_info), K(ret));
|
||||
} else if (OB_FAIL(session_info->if_aggr_pushdown_allowed(push_distinct))) {
|
||||
LOG_WARN("fail to get aggr_pushdown_allowed", K(ret));
|
||||
} else if (!push_distinct && !get_log_plan_hint().pushdown_distinct()) {
|
||||
OPT_TRACE("session info disable pushdown distinct");
|
||||
} else {
|
||||
distinct_helper.can_basic_pushdown_ = true;
|
||||
OPT_TRACE("try pushdown distinct");
|
||||
} else if (OB_FAIL(check_basic_distinct_pushdown(distinct_helper.can_basic_pushdown_))) {
|
||||
LOG_WARN("failed to check can basic distinct pushdown", K(ret));
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
@ -6050,7 +6037,7 @@ int ObLogPlan::check_can_pullup_gi(ObLogicalOperator &top,
|
||||
can_pullup = true;
|
||||
} else if (need_sort || !top.get_is_local_order() || top.is_exchange_allocated()) {
|
||||
/* do nothing */
|
||||
} else if (OB_FAIL(top.has_window_function_below(has_win_func))) {
|
||||
} else if (OB_FAIL(top.check_has_op_below(LOG_WINDOW_FUNCTION, has_win_func))) {
|
||||
LOG_WARN("failed to check has window function below", K(ret));
|
||||
} else {
|
||||
can_pullup = !has_win_func;
|
||||
@ -7866,11 +7853,15 @@ int ObLogPlan::inner_candi_allocate_subplan_filter(ObIArray<ObLogPlan*> &subplan
|
||||
ObSEArray<ObSEArray<CandidatePlan, 4>, 8> best_subplan_list;
|
||||
ObSEArray<ObSEArray<CandidatePlan, 4>, 8> best_dist_subplan_list;
|
||||
ObSEArray<CandidatePlan, 4> subquery_plans;
|
||||
const bool has_onetime = !onetime_idxs.is_empty();
|
||||
int64_t dist_methods = DIST_INVALID_METHOD;
|
||||
if (OB_FAIL(prepare_subplan_candidate_list(subplans, params, best_subplan_list,
|
||||
best_dist_subplan_list))) {
|
||||
LOG_WARN("failed to prepare subplan candidate list", K(ret));
|
||||
} else if (OB_FAIL(get_valid_subplan_filter_dist_method(subplans, for_cursor_expr, false,
|
||||
} else if (OB_FAIL(get_valid_subplan_filter_dist_method(subplans,
|
||||
for_cursor_expr,
|
||||
has_onetime,
|
||||
false,
|
||||
dist_methods))) {
|
||||
LOG_WARN("failed to get valid subplan filter dist method", K(ret));
|
||||
} else if (DIST_INVALID_METHOD != dist_methods &&
|
||||
@ -7892,7 +7883,10 @@ int ObLogPlan::inner_candi_allocate_subplan_filter(ObIArray<ObLogPlan*> &subplan
|
||||
OPT_TRACE("success to generate subplan filter plan with hint");
|
||||
} else if (OB_FAIL(get_log_plan_hint().check_status())) {
|
||||
LOG_WARN("failed to generate plans with hint", K(ret));
|
||||
} else if (OB_FAIL(get_valid_subplan_filter_dist_method(subplans, for_cursor_expr, true,
|
||||
} else if (OB_FAIL(get_valid_subplan_filter_dist_method(subplans,
|
||||
for_cursor_expr,
|
||||
has_onetime,
|
||||
true,
|
||||
dist_methods))) {
|
||||
LOG_WARN("failed to get valid subplan filter dist method", K(ret));
|
||||
} else if (OB_FAIL(inner_candi_allocate_subplan_filter(best_subplan_list,
|
||||
@ -7986,6 +7980,7 @@ int ObLogPlan::prepare_subplan_candidate_list(ObIArray<ObLogPlan*> &subplans,
|
||||
|
||||
int ObLogPlan::get_valid_subplan_filter_dist_method(ObIArray<ObLogPlan*> &subplans,
|
||||
const bool for_cursor_expr,
|
||||
const bool has_onetime,
|
||||
const bool ignore_hint,
|
||||
int64_t &dist_methods)
|
||||
{
|
||||
@ -8029,6 +8024,11 @@ int ObLogPlan::get_valid_subplan_filter_dist_method(ObIArray<ObLogPlan*> &subpla
|
||||
dist_methods &= ~DIST_PARTITION_NONE;
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret) && has_onetime) {
|
||||
dist_methods &= ~DIST_NONE_ALL;
|
||||
OPT_TRACE("SPF will not use DIST_NONE_ALL/DIST_HASH_ALL/DIST_RANDOM_ALL method due to onetime subquery");
|
||||
}
|
||||
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (for_cursor_expr || contain_recursive_cte) {
|
||||
dist_methods &= (DIST_BASIC_METHOD | DIST_PULL_TO_LOCAL);
|
||||
@ -8305,7 +8305,7 @@ int ObLogPlan::get_subplan_filter_distributed_method(ObLogicalOperator *&top,
|
||||
if (OB_SUCC(ret) && (distributed_methods & DistAlgo::DIST_NONE_ALL)) {
|
||||
if (OB_FAIL(check_if_match_none_all(top, subquery_ops, is_none_all))) {
|
||||
LOG_WARN("failed to check if match repart", K(ret));
|
||||
} else if (is_none_all && !has_onetime) {
|
||||
} else if (is_none_all) {
|
||||
distributed_methods = DistAlgo::DIST_NONE_ALL;
|
||||
OPT_TRACE("SPF will use none all method");
|
||||
} else {
|
||||
@ -8895,6 +8895,8 @@ int ObLogPlan::allocate_subplan_filter_as_top(ObLogicalOperator *&top,
|
||||
LOG_WARN("failed to add init plan idxs", K(ret));
|
||||
} else if (OB_FAIL(spf_node->add_onetime_idxs(onetime_idxs))) {
|
||||
LOG_WARN("failed to add onetime idxs", K(ret));
|
||||
} else if (OB_FAIL(spf_node->compute_spf_batch_rescan())) {
|
||||
LOG_WARN("failed to compute spf batch rescan", K(ret));
|
||||
} else if (OB_FAIL(spf_node->compute_property())) {
|
||||
LOG_WARN("failed to compute property", K(ret));
|
||||
} else {
|
||||
@ -9037,7 +9039,9 @@ int ObLogPlan::plan_tree_traverse(const TraverseOp &operation, void *ctx)
|
||||
break;
|
||||
}
|
||||
case ALLOC_EXPR: {
|
||||
if (OB_FAIL(alloc_expr_ctx.flattern_expr_map_.create(128, "ExprAlloc"))) {
|
||||
if (OB_FAIL(set_use_batch_for_table_scan(get_plan_root(), true, false))) {
|
||||
LOG_WARN("failed to set use batch for table scan", K(ret));
|
||||
} else if (OB_FAIL(alloc_expr_ctx.flattern_expr_map_.create(128, "ExprAlloc"))) {
|
||||
LOG_WARN("failed to init hash map", K(ret));
|
||||
} else {
|
||||
ctx = &alloc_expr_ctx;
|
||||
@ -9118,69 +9122,6 @@ int ObLogPlan::plan_tree_traverse(const TraverseOp &operation, void *ctx)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogPlan::contains_limit_or_pushdown_limit(ObLogicalOperator *op,
|
||||
bool &contains)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
contains = false;
|
||||
if (OB_ISNULL(op)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("invalid op", K(ret));
|
||||
} else if (log_op_def::LOG_LIMIT == op->get_type()) {
|
||||
contains = true;
|
||||
} else if (log_op_def::LOG_TABLE_SCAN == op->get_type()) {
|
||||
ObLogTableScan *ts = static_cast<ObLogTableScan*>(op);
|
||||
if (NULL != ts->get_limit_expr()) {
|
||||
contains = true;
|
||||
}
|
||||
} else {
|
||||
for (int64_t i = 0; OB_SUCC(ret) && !contains && i < op->get_num_of_child(); ++i) {
|
||||
ObLogicalOperator *child = op->get_child(i);
|
||||
if (OB_ISNULL(child)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("invalid child", K(ret));
|
||||
} else if (OB_FAIL(SMART_CALL(contains_limit_or_pushdown_limit(child, contains)))) {
|
||||
LOG_WARN("failed to check contains limit", K(ret));
|
||||
} else {/*do nothing*/}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogPlan::contains_startup_with_exec_param(ObLogicalOperator *op,
|
||||
bool &contains)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
contains = false;
|
||||
if (OB_ISNULL(op)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("invalid op", K(ret));
|
||||
} else {
|
||||
ObIArray<ObRawExpr*> &startup_exprs = op->get_startup_exprs();
|
||||
for (int64_t i = 0; OB_SUCC(ret) && !contains && i < startup_exprs.count(); ++i) {
|
||||
ObRawExpr *expr = startup_exprs.at(i);
|
||||
if (OB_ISNULL(expr)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpect null expr", K(ret));
|
||||
} else if (expr->has_flag(CNT_DYNAMIC_PARAM)) {
|
||||
contains = true;
|
||||
} else {/*do nothing*/}
|
||||
}
|
||||
if (OB_SUCC(ret) && !contains) {
|
||||
for (int64_t i = 0; OB_SUCC(ret) && !contains && i < op->get_num_of_child(); ++i) {
|
||||
ObLogicalOperator *child = op->get_child(i);
|
||||
if (OB_ISNULL(child)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("invalid child", K(ret));
|
||||
} else if (OB_FAIL(SMART_CALL(contains_startup_with_exec_param(child, contains)))) {
|
||||
LOG_WARN("failed to check contains startup with exec param", K(ret));
|
||||
} else {/*do nothing*/}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogPlan::init_onetime_subquery_info()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -9751,6 +9692,10 @@ int ObLogPlan::compute_plan_relationship(const CandidatePlan &first_candi_plan,
|
||||
OB_ISNULL(second_plan = second_candi_plan.plan_tree_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected null", K(stmt), K(first_plan), K(second_plan), K(ret));
|
||||
} else if (OB_FAIL(compute_rescan_plan_relationship(*first_plan, *second_plan, plan_rel))) {
|
||||
LOG_WARN("failed to compute rescan plan relationship", K(ret));
|
||||
} else if (DominateRelation::OBJ_UNCOMPARABLE != plan_rel) {
|
||||
|
||||
} else {
|
||||
DominateRelation temp_relation;
|
||||
int64_t left_dominated_count = 0;
|
||||
@ -9870,6 +9815,82 @@ int ObLogPlan::compute_plan_relationship(const CandidatePlan &first_candi_plan,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogPlan::compute_rescan_plan_relationship(const ObLogicalOperator &first_plan,
|
||||
const ObLogicalOperator &second_plan,
|
||||
DominateRelation &relation)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
relation = DominateRelation::OBJ_UNCOMPARABLE;
|
||||
if (get_is_rescan_subplan()) {
|
||||
bool first_is_px_with_das = !first_plan.is_match_all() && first_plan.get_contains_das_op();
|
||||
bool second_is_px_with_das = !second_plan.is_match_all() && second_plan.get_contains_das_op();
|
||||
if (first_is_px_with_das && !second_is_px_with_das) {
|
||||
relation = DominateRelation::OBJ_RIGHT_DOMINATE;
|
||||
OPT_TRACE("right plan dominate left plan because of px rescan plan use das op");
|
||||
} else if (!first_is_px_with_das && second_is_px_with_das) {
|
||||
relation = DominateRelation::OBJ_LEFT_DOMINATE;
|
||||
OPT_TRACE("left plan dominate right plan because of px rescan plan use das op");
|
||||
}
|
||||
}
|
||||
if (log_op_def::LOG_SUBPLAN_FILTER == first_plan.get_type()
|
||||
&& log_op_def::LOG_SUBPLAN_FILTER == second_plan.get_type()) {
|
||||
const ObLogSubPlanFilter *first_spf = static_cast<const ObLogSubPlanFilter*>(&first_plan);
|
||||
const ObLogSubPlanFilter *second_spf = static_cast<const ObLogSubPlanFilter*>(&second_plan);
|
||||
bool first_right_local_rescan = false;
|
||||
bool second_right_local_rescan = false;
|
||||
bool first_can_px_batch_rescan = false;
|
||||
bool second_can_px_batch_rescan = false;
|
||||
bool first_rescan_contain_match_all = false;
|
||||
bool second_rescan_contain_match_all = false;
|
||||
if (!first_spf->enable_das_group_rescan() && second_spf->enable_das_group_rescan()) {
|
||||
relation = DominateRelation::OBJ_RIGHT_DOMINATE;
|
||||
OPT_TRACE("right plan dominate left plan because of group rescan subplan filter");
|
||||
} else if (first_spf->enable_das_group_rescan() && !second_spf->enable_das_group_rescan()) {
|
||||
relation = DominateRelation::OBJ_LEFT_DOMINATE;
|
||||
OPT_TRACE("left plan dominate right plan because of group rescan subplan filter");
|
||||
} else if (OB_FAIL(first_spf->check_right_is_local_scan(first_right_local_rescan))
|
||||
|| OB_FAIL(second_spf->check_right_is_local_scan(second_right_local_rescan))) {
|
||||
LOG_WARN("failed to check right is local rescan", K(ret));
|
||||
} else if (first_spf->enable_das_group_rescan() && second_spf->enable_das_group_rescan()) {
|
||||
if (first_spf->get_parallel() != second_spf->get_parallel()) {
|
||||
/* do nothing */
|
||||
} else if (!first_right_local_rescan && second_right_local_rescan) {
|
||||
relation = DominateRelation::OBJ_RIGHT_DOMINATE;
|
||||
OPT_TRACE("right path dominate left path because of right local group rescan");
|
||||
} else if (first_right_local_rescan && !second_right_local_rescan) {
|
||||
relation = DominateRelation::OBJ_LEFT_DOMINATE;
|
||||
OPT_TRACE("left path dominate right path because of right local group rescan");
|
||||
}
|
||||
} else if (!first_right_local_rescan && second_right_local_rescan) {
|
||||
relation = DominateRelation::OBJ_RIGHT_DOMINATE;
|
||||
OPT_TRACE("right plan dominate left plan because of right local rescan subplan filter");
|
||||
} else if (first_right_local_rescan && !second_right_local_rescan) {
|
||||
relation = DominateRelation::OBJ_LEFT_DOMINATE;
|
||||
OPT_TRACE("left plan dominate right plan because of right local rescan subplan filter");
|
||||
} else if (first_right_local_rescan && second_right_local_rescan) {
|
||||
/* do nothing */
|
||||
} else if (OB_FAIL(first_spf->pre_check_spf_can_px_batch_rescan(first_can_px_batch_rescan, first_rescan_contain_match_all))
|
||||
|| OB_FAIL(second_spf->pre_check_spf_can_px_batch_rescan(second_can_px_batch_rescan, second_rescan_contain_match_all))) {
|
||||
LOG_WARN("failed to pre check spf can px batch rescan", K(ret));
|
||||
} else if ((!first_can_px_batch_rescan || (first_rescan_contain_match_all && !second_rescan_contain_match_all))
|
||||
&& second_can_px_batch_rescan) {
|
||||
relation = DominateRelation::OBJ_RIGHT_DOMINATE;
|
||||
OPT_TRACE("right plan dominate left plan because of px batch rescan subplan filter");
|
||||
} else if (first_can_px_batch_rescan
|
||||
&& (!second_can_px_batch_rescan || (!first_rescan_contain_match_all && second_rescan_contain_match_all))) {
|
||||
relation = DominateRelation::OBJ_LEFT_DOMINATE;
|
||||
OPT_TRACE("left plan dominate right plan because of px batch rescan subplan filter");
|
||||
} else {
|
||||
/* do nothing */
|
||||
}
|
||||
LOG_TRACE("finish compute spf rescan plan relationship",
|
||||
K(first_spf->enable_das_group_rescan()), K(second_spf->enable_das_group_rescan()),
|
||||
K(first_right_local_rescan), K(second_right_local_rescan),
|
||||
K(first_can_px_batch_rescan), K(second_can_px_batch_rescan));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogPlan::compute_pipeline_relationship(const ObLogicalOperator &first_plan,
|
||||
const ObLogicalOperator &second_plan,
|
||||
DominateRelation &relation)
|
||||
@ -10443,86 +10464,6 @@ int ObLogPlan::get_source_table_info(ObLogicalOperator &top,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogPlan::collect_subq_pushdown_filter_table_relids(const ObIArray<ObRawExpr*> &conditions)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const ObDMLStmt *stmt = NULL;
|
||||
ObSEArray<ObRawExpr*, 4> column_exprs;
|
||||
ObSEArray<ObColumnRefRawExpr*, 4> pushdown_col_exprs;
|
||||
ObSEArray<ObColumnRefRawExpr*, 4> all_pushdown_col_exprs;
|
||||
ObSEArray<uint64_t, 4> table_ids;
|
||||
bool contribute_query_range = false;
|
||||
if (OB_ISNULL(stmt = get_stmt())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("invalid stmt", K(ret));
|
||||
} else {
|
||||
for (int64_t i = 0; i < conditions.count(); ++i) {
|
||||
ObRawExpr *expr = conditions.at(i);
|
||||
column_exprs.reuse();
|
||||
table_ids.reuse();
|
||||
if (OB_ISNULL(expr)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("invalid expr", K(expr));
|
||||
} else if (!expr->has_flag(CNT_DYNAMIC_PARAM) ||
|
||||
expr->has_flag(CNT_ONETIME) ||
|
||||
expr->has_flag(CNT_PSEUDO_COLUMN) ||
|
||||
expr->has_flag(CNT_PRIOR) ||
|
||||
expr->has_flag(CNT_ROWNUM) ||
|
||||
T_OP_NE == expr->get_expr_type()) {
|
||||
// do nothing
|
||||
} else if (OB_FAIL(ObRawExprUtils::extract_column_exprs(expr, column_exprs))) {
|
||||
LOG_WARN("failed to extract column exprs", K(ret));
|
||||
} else {
|
||||
for (int64_t j = 0; OB_SUCC(ret) && j < column_exprs.count(); ++j) {
|
||||
ObColumnRefRawExpr *col_expr = NULL;
|
||||
if (OB_ISNULL(column_exprs.at(j)) ||
|
||||
!column_exprs.at(j)->is_column_ref_expr()) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected null", K(ret));
|
||||
} else if (OB_FALSE_IT(col_expr = static_cast<ObColumnRefRawExpr*>(column_exprs.at(j)))) {
|
||||
} else if (OB_FAIL(add_var_to_array_no_dup(table_ids, col_expr->get_table_id()))) {
|
||||
LOG_WARN("failed to add var to array no dup", K(ret));
|
||||
}
|
||||
}
|
||||
for (int64_t j = 0; OB_SUCC(ret) && j < table_ids.count(); ++j) {
|
||||
pushdown_col_exprs.reuse();
|
||||
if (OB_FAIL(ObTransformUtils::get_simple_filter_column(stmt,
|
||||
expr,
|
||||
table_ids.at(j),
|
||||
pushdown_col_exprs))) {
|
||||
LOG_WARN("failed to get simple filter column", K(ret));
|
||||
} else if (OB_FAIL(append_array_no_dup(all_pushdown_col_exprs,
|
||||
pushdown_col_exprs))) {
|
||||
LOG_WARN("failed to append array no dup", K(ret));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < all_pushdown_col_exprs.count(); ++i) {
|
||||
ObColumnRefRawExpr *col_expr = all_pushdown_col_exprs.at(i);
|
||||
int64_t table_index = OB_INVALID_ID;
|
||||
contribute_query_range = false;
|
||||
if (OB_ISNULL(col_expr)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected null", K(ret));
|
||||
} else if (OB_FALSE_IT(table_index = stmt->get_table_bit_index(col_expr->get_table_id()))) {
|
||||
} else if (subq_pushdown_filter_table_set_.has_member(table_index)) {
|
||||
// do nothing
|
||||
} else if (OB_FAIL(ObTransformUtils::is_match_index(get_optimizer_context().get_sql_schema_guard(),
|
||||
stmt,
|
||||
col_expr,
|
||||
contribute_query_range))) {
|
||||
LOG_WARN("failed to check is match index", K(ret));
|
||||
} else if (!contribute_query_range) {
|
||||
// do nothing
|
||||
} else if (OB_FAIL(subq_pushdown_filter_table_set_.add_member(table_index))) {
|
||||
LOG_WARN("failed to add members", K(ret));
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogPlan::init_plan_info()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -10849,6 +10790,8 @@ int ObLogPlan::do_post_plan_processing()
|
||||
if (OB_ISNULL(root = get_plan_root())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected null", K(ret));
|
||||
} else if (OB_FAIL(set_use_batch_for_table_scan(root, false, false))) {
|
||||
LOG_WARN("failed to set use batch for table scan", K(ret));
|
||||
} else if (OB_FAIL(adjust_final_plan_info(root))) {
|
||||
LOG_WARN("failed to adjust parent-child relationship", K(ret));
|
||||
} else if (OB_FAIL(remove_duplicate_constraints())) {
|
||||
@ -11037,12 +10980,6 @@ int ObLogPlan::adjust_final_plan_info(ObLogicalOperator *&op)
|
||||
LOG_WARN("failed to perform gather stat replace");
|
||||
} else if (OB_FAIL(op->reorder_filter_exprs())) {
|
||||
LOG_WARN("failed to reorder filter exprs", K(ret));
|
||||
} else if (log_op_def::LOG_JOIN == op->get_type() &&
|
||||
OB_FAIL(static_cast<ObLogJoin*>(op)->check_and_set_use_batch())) {
|
||||
LOG_WARN("failed to set use batch nlj", K(ret));
|
||||
} else if (log_op_def::LOG_SUBPLAN_FILTER == op->get_type() &&
|
||||
OB_FAIL(static_cast<ObLogSubPlanFilter*>(op)->check_and_set_das_group_rescan())) {
|
||||
LOG_WARN("failed to set use batch spf", K(ret));
|
||||
} else if (log_op_def::LOG_JOIN == op->get_type() &&
|
||||
OB_FAIL(static_cast<ObLogJoin*>(op)->adjust_join_conds(static_cast<ObLogJoin *>(op)->get_join_conditions()))) {
|
||||
LOG_WARN("failed to adjust join conds", K(ret));
|
||||
@ -11052,6 +10989,86 @@ int ObLogPlan::adjust_final_plan_info(ObLogicalOperator *&op)
|
||||
return ret;
|
||||
}
|
||||
|
||||
// 1. set use batch for table scan
|
||||
// 2. clear function storage pushdown aggr for batch rescan table scan
|
||||
int ObLogPlan::set_use_batch_for_table_scan(ObLogicalOperator *op, bool check_gi, bool in_batch_rescan)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_ISNULL(op)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected null", K(ret));
|
||||
} else if (op->is_table_scan()) {
|
||||
ObLogTableScan *scan_op = static_cast<ObLogTableScan*>(op);
|
||||
scan_op->set_use_batch(in_batch_rescan);
|
||||
if (in_batch_rescan) {
|
||||
scan_op->get_pushdown_aggr_exprs().reuse();
|
||||
}
|
||||
} else if (check_gi && OB_FAIL(reset_use_batch_due_to_gi_allocated_below(op))) {
|
||||
LOG_WARN("failed to reset use batch due to gi allocated below", K(ret));
|
||||
} else {
|
||||
bool is_batch_rescan_op = false;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < op->get_num_of_child(); i++) {
|
||||
is_batch_rescan_op = in_batch_rescan;
|
||||
if (0 == i) {
|
||||
} else if (log_op_def::LOG_JOIN == op->get_type()) {
|
||||
is_batch_rescan_op |= static_cast<ObLogJoin*>(op)->can_use_batch_nlj();
|
||||
} else if (log_op_def::LOG_SUBPLAN_FILTER == op->get_type()) {
|
||||
ObLogSubPlanFilter *spf = static_cast<ObLogSubPlanFilter*>(op);
|
||||
is_batch_rescan_op |= spf->enable_das_group_rescan()
|
||||
&& !spf->get_onetime_idxs().has_member(i)
|
||||
&& !spf->get_initplan_idxs().has_member(i);
|
||||
}
|
||||
if (OB_FAIL(SMART_CALL(set_use_batch_for_table_scan(op->get_child(i), check_gi, is_batch_rescan_op)))) {
|
||||
LOG_WARN("failed to set use batch for table scan", K(ret), K(i), K(op->get_type()),
|
||||
K(op->get_name()), K(op->get_op_id()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogPlan::reset_use_batch_due_to_gi_allocated_below(ObLogicalOperator *op)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_ISNULL(op)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected null", K(ret), K(op));
|
||||
} else if (log_op_def::LOG_JOIN == op->get_type()
|
||||
&& static_cast<ObLogJoin*>(op)->can_use_batch_nlj()) {
|
||||
bool has_gi_below = false;
|
||||
if (OB_ISNULL(op->get_child(1))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected null right child", K(ret));
|
||||
} else if (OB_FAIL(op->get_child(1)->check_has_op_below(LOG_GRANULE_ITERATOR, has_gi_below))) {
|
||||
LOG_WARN("failed to check has gi below", K(ret));
|
||||
} else if (!has_gi_below) {
|
||||
/* do nothing */
|
||||
} else {
|
||||
static_cast<ObLogJoin*>(op)->set_can_use_batch_nlj(false);
|
||||
LOG_TRACE("reset batch nlj due to gi allocated", K(op->get_type()), K(op->get_name()), K(op->get_op_id()));
|
||||
}
|
||||
} else if (log_op_def::LOG_SUBPLAN_FILTER == op->get_type()
|
||||
&& static_cast<ObLogSubPlanFilter*>(op)->enable_das_group_rescan()) {
|
||||
ObLogSubPlanFilter *spf = static_cast<ObLogSubPlanFilter*>(op);
|
||||
bool has_gi_below = false;
|
||||
for (int64_t i = 1; !has_gi_below && OB_SUCC(ret) && i < spf->get_num_of_child(); i++) {
|
||||
if (OB_ISNULL(spf->get_child(i))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected null child", K(ret), K(i));
|
||||
} else if (spf->get_onetime_idxs().has_member(i) || spf->get_initplan_idxs().has_member(i)) {
|
||||
/* do nothing */
|
||||
} else if (OB_FAIL(spf->get_child(i)->check_has_op_below(LOG_GRANULE_ITERATOR, has_gi_below))) {
|
||||
LOG_WARN("failed to check has gi below", K(ret));
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret) && has_gi_below) {
|
||||
spf->set_enable_das_group_rescan(false);
|
||||
LOG_TRACE("reset spf group rescan due to gi allocated", K(op->get_type()), K(op->get_name()), K(op->get_op_id()));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogPlan::set_identify_seq_expr_for_recursive_union_all(ObLogicalOperator *op)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -13849,6 +13866,28 @@ int ObLogPlan::perform_gather_stat_replace(ObLogicalOperator *op)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogPlan::check_basic_distinct_pushdown(bool &can_push)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObSQLSessionInfo *session_info = NULL;
|
||||
bool sys_var_allow_push = false;
|
||||
can_push = false;
|
||||
if (get_log_plan_hint().no_pushdown_distinct()) {
|
||||
OPT_TRACE("hint disable pushdown distinct");
|
||||
} else if (OB_ISNULL(session_info = get_optimizer_context().get_session_info())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected null", K(session_info), K(ret));
|
||||
} else if (OB_FAIL(session_info->if_aggr_pushdown_allowed(sys_var_allow_push))) {
|
||||
LOG_WARN("failed to get aggr_pushdown_allowed", K(ret));
|
||||
} else if (!sys_var_allow_push && !get_log_plan_hint().pushdown_distinct()) {
|
||||
OPT_TRACE("session info disable pushdown distinct");
|
||||
} else {
|
||||
can_push = true;
|
||||
OPT_TRACE("try pushdown distinct");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogPlan::check_stmt_is_all_distinct_col(const ObSelectStmt *stmt,
|
||||
const ObIArray<ObRawExpr*> &distinct_exprs,
|
||||
bool &is_all_distinct_col)
|
||||
|
@ -254,6 +254,9 @@ public:
|
||||
|
||||
int adjust_final_plan_info(ObLogicalOperator *&op);
|
||||
|
||||
int set_use_batch_for_table_scan(ObLogicalOperator *op, bool check_gi, bool in_batch_rescan);
|
||||
int reset_use_batch_due_to_gi_allocated_below(ObLogicalOperator *op);
|
||||
|
||||
int set_identify_seq_expr_for_recursive_union_all(ObLogicalOperator *op);
|
||||
|
||||
int set_identify_seq_expr_for_fake_cte(ObLogicalOperator *op, ObRawExpr *expr, bool &is_valid);
|
||||
@ -366,34 +369,12 @@ public:
|
||||
|
||||
//get expr selectivity from predicate_selectivities_
|
||||
double get_expr_selectivity(const ObRawExpr *expr, bool &found);
|
||||
|
||||
int can_be_late_materialization(bool &can_be);
|
||||
|
||||
int check_late_materialization_project(const uint64_t table_id,
|
||||
const common::ObIArray<ObRawExpr*> &filter_exprs,
|
||||
const common::ObIArray<ObRawExpr*> &sort_exprs,
|
||||
const common::ObIArray<ObRawExpr*> &index_keys,
|
||||
bool &need,
|
||||
common::ObIArray<ObRawExpr*> &pre_access_columns,
|
||||
common::ObIArray<ObRawExpr*> &project_columns);
|
||||
|
||||
int get_pre_project_cost(ObLogicalOperator *top,
|
||||
ObLogicalOperator *scan,
|
||||
common::ObIArray<ObRawExpr*> &index_columns,
|
||||
bool index_back,
|
||||
bool need_set,
|
||||
double &cost);
|
||||
|
||||
int check_late_materialization_cost(ObLogicalOperator *top,
|
||||
ObLogicalOperator *scan,
|
||||
common::ObIArray<ObRawExpr*> &index_columns,
|
||||
common::ObIArray<ObRawExpr*> &table_columns,
|
||||
bool index_back,
|
||||
double min_cost,
|
||||
bool &need,
|
||||
double &get_cost,
|
||||
double &join_cost);
|
||||
|
||||
static int select_one_server(const common::ObAddr &selected_server,
|
||||
common::ObIArray<ObCandiTableLoc*> &phy_tbl_loc_info_list);
|
||||
|
||||
@ -590,11 +571,6 @@ public:
|
||||
int allocate_values_table_path(ValuesTablePath *values_table_path,
|
||||
ObLogicalOperator *&out_access_path_op);
|
||||
|
||||
int get_has_global_index_filters(const ObIArray<ObRawExpr*> &filter_exprs,
|
||||
const ObIArray<uint64_t> &index_columns,
|
||||
bool &has_index_scan_filter,
|
||||
bool &has_index_lookup_filter) ;
|
||||
|
||||
int allocate_json_table_path(JsonTablePath *json_table_path,
|
||||
ObLogicalOperator *&out_access_path_op);
|
||||
|
||||
@ -803,6 +779,8 @@ public:
|
||||
const ObIArray<ObRawExpr*> &distinct_exprs,
|
||||
bool &is_all_distinct_col);
|
||||
|
||||
int check_basic_distinct_pushdown(bool &can_push);
|
||||
|
||||
int check_storage_distinct_pushdown(const ObIArray<ObRawExpr*> &distinct_exprs,
|
||||
bool &can_push);
|
||||
|
||||
@ -1092,6 +1070,7 @@ public:
|
||||
ObIArray<ObSEArray<CandidatePlan, 4>> &dist_best_list);
|
||||
int get_valid_subplan_filter_dist_method(ObIArray<ObLogPlan*> &subplans,
|
||||
const bool for_cursor_expr,
|
||||
const bool has_onetime,
|
||||
const bool ignore_hint,
|
||||
int64_t &dist_methods);
|
||||
|
||||
@ -1207,13 +1186,15 @@ public:
|
||||
const ObRawExprSets &get_empty_expr_sets() { return empty_expr_sets_; }
|
||||
const ObFdItemSet &get_empty_fd_item_set() { return empty_fd_item_set_; }
|
||||
const ObRelIds &get_empty_table_set() { return empty_table_set_; }
|
||||
ObRelIds &get_subq_pdfilter_tset() { return subq_pushdown_filter_table_set_; }
|
||||
inline common::ObIArray<ObRawExpr *> &get_subquery_filters()
|
||||
{
|
||||
return subquery_filters_;
|
||||
}
|
||||
int init_plan_info();
|
||||
int collect_subq_pushdown_filter_table_relids(const ObIArray<ObRawExpr*> &quals);
|
||||
int init_rescan_info_for_query_ref(const ObLogPlan &parent_plan, const bool is_rescan_subquery);
|
||||
int init_rescan_info_for_subquery_paths(const ObLogPlan &parent_plan,
|
||||
const bool is_inner_path,
|
||||
const bool is_semi_anti_join_inner_path);
|
||||
|
||||
EqualSets &get_equal_sets() { return equal_sets_; }
|
||||
const EqualSets &get_equal_sets() const { return equal_sets_; }
|
||||
@ -1232,6 +1213,8 @@ public:
|
||||
inline const OptSelectivityCtx& get_selectivity_ctx() const { return selectivity_ctx_; }
|
||||
inline bool get_is_subplan_scan() const { return is_subplan_scan_; }
|
||||
inline void set_is_subplan_scan(bool is_subplan_scan) { is_subplan_scan_ = is_subplan_scan; }
|
||||
inline bool get_is_rescan_subplan() const { return is_rescan_subplan_; }
|
||||
inline bool get_disable_child_batch_rescan() const { return disable_child_batch_rescan_; }
|
||||
inline bool get_is_parent_set_distinct() const { return is_parent_set_distinct_; }
|
||||
inline void set_is_parent_set_distinct(bool is_parent_set_distinct)
|
||||
{ is_parent_set_distinct_ = is_parent_set_distinct; }
|
||||
@ -1285,12 +1268,6 @@ public:
|
||||
ObIArray<ObQueryRefRawExpr *> &onetime_query_refs,
|
||||
const bool for_on_condition);
|
||||
|
||||
int contains_startup_with_exec_param(ObLogicalOperator *op,
|
||||
bool &contains);
|
||||
|
||||
int contains_limit_or_pushdown_limit(ObLogicalOperator *op,
|
||||
bool &contains);
|
||||
|
||||
int replace_generate_column_exprs(ObLogicalOperator *op);
|
||||
int generate_old_column_values_exprs(ObLogicalOperator *root);
|
||||
int generate_tsc_replace_exprs_pair(ObLogTableScan *op);
|
||||
@ -1497,7 +1474,9 @@ protected:
|
||||
int compute_plan_relationship(const CandidatePlan &first_plan,
|
||||
const CandidatePlan &second_plan,
|
||||
DominateRelation &relation);
|
||||
|
||||
int compute_rescan_plan_relationship(const ObLogicalOperator &first_plan,
|
||||
const ObLogicalOperator &second_plan,
|
||||
DominateRelation &relation);
|
||||
int compute_pipeline_relationship(const ObLogicalOperator &first_plan,
|
||||
const ObLogicalOperator &second_plan,
|
||||
DominateRelation &relation);
|
||||
@ -1898,6 +1877,8 @@ private:
|
||||
uint64_t max_op_id_;
|
||||
bool is_subplan_scan_; // 当前plan是否是一个subplan scan
|
||||
bool is_parent_set_distinct_;
|
||||
bool is_rescan_subplan_; // generate subquery subplan for subplan filter or inner subquery path
|
||||
bool disable_child_batch_rescan_; // before version 4_2_5, semi/anti join and subplan filter child op can not use batch rescan
|
||||
ObSqlTempTableInfo *temp_table_info_; // current plan is a temp table
|
||||
// 从where condition中抽出的常量表达式
|
||||
common::ObSEArray<ObRawExpr*, 4, common::ModulePageAllocator, true> const_exprs_;
|
||||
@ -1911,7 +1892,6 @@ private:
|
||||
// all basic table meta after base table predicate
|
||||
OptTableMetas update_table_metas_;
|
||||
OptSelectivityCtx selectivity_ctx_;
|
||||
ObRelIds subq_pushdown_filter_table_set_;
|
||||
// have been allocated for update table list
|
||||
common::ObSEArray<int64_t, 1, common::ModulePageAllocator, true> alloc_sfu_list_;
|
||||
struct PartIdExpr {
|
||||
|
@ -761,11 +761,21 @@ int ObLogSet::print_outline_data(PlanText &plan_text)
|
||||
const ObDMLStmt *stmt = NULL;
|
||||
ObString qb_name;
|
||||
ObPQSetHint hint;
|
||||
bool has_push_down = false;
|
||||
if (OB_ISNULL(get_plan()) || OB_ISNULL(stmt = get_plan()->get_stmt())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected NULL", K(ret), K(get_plan()), K(stmt));
|
||||
} else if (OB_FAIL(stmt->get_qb_name(qb_name))) {
|
||||
LOG_WARN("fail to get qb_name", K(ret), K(stmt->get_stmt_id()));
|
||||
} else if (OB_FAIL(check_has_push_down(has_push_down))) {
|
||||
LOG_WARN("failed to check has push down", K(ret));
|
||||
} else if (has_push_down &&
|
||||
OB_FAIL(BUF_PRINTF("%s%s(@\"%.*s\")",
|
||||
ObQueryHint::get_outline_indent(plan_text.is_oneline_),
|
||||
ObHint::get_hint_name(T_DISTINCT_PUSHDOWN),
|
||||
qb_name.length(),
|
||||
qb_name.ptr()))) {
|
||||
LOG_WARN("fail to print buffer", K(ret), K(buf), K(buf_len), K(pos));
|
||||
} else if (HASH_SET == set_algo_ &&
|
||||
OB_FAIL(BUF_PRINTF("%s%s(@\"%.*s\")",
|
||||
ObQueryHint::get_outline_indent(plan_text.is_oneline_),
|
||||
@ -791,6 +801,7 @@ int ObLogSet::print_used_hint(PlanText &plan_text)
|
||||
LOG_WARN("unexpected NULL", K(ret), K(get_plan()));
|
||||
} else {
|
||||
const ObHint *use_hash = get_plan()->get_log_plan_hint().get_normal_hint(T_USE_HASH_SET);
|
||||
const ObHint *pushdown = get_plan()->get_log_plan_hint().get_normal_hint(T_DISTINCT_PUSHDOWN);
|
||||
const bool algo_match = NULL != use_hash &&
|
||||
((HASH_SET == set_algo_ && use_hash->is_enable_hint())
|
||||
|| (MERGE_SET == set_algo_ && use_hash->is_disable_hint()));
|
||||
@ -801,6 +812,17 @@ int ObLogSet::print_used_hint(PlanText &plan_text)
|
||||
LOG_WARN("failed to get used pq set hint", K(ret));
|
||||
} else if (NULL != used_pq_hint && OB_FAIL(used_pq_hint->print_hint(plan_text))) {
|
||||
LOG_WARN("failed to print pq_set hint for set", K(ret), K(*used_pq_hint));
|
||||
} else if (NULL != pushdown) {
|
||||
bool has_push_down = false;
|
||||
if (OB_FAIL(check_has_push_down(has_push_down))) {
|
||||
LOG_WARN("failed to check has push down", K(ret));
|
||||
} else {
|
||||
bool pushdown_match = has_push_down ? pushdown->is_enable_hint()
|
||||
: pushdown->is_disable_hint();
|
||||
if (pushdown_match && OB_FAIL(pushdown->print_hint(plan_text))) {
|
||||
LOG_WARN("failed to print used push down hint for set", K(ret), KPC(pushdown));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
@ -874,6 +896,30 @@ int ObLogSet::construct_pq_set_hint(ObPQSetHint &hint)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogSet::check_has_push_down(bool &has_push_down)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
has_push_down = false;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && !has_push_down && i < get_num_of_child(); ++i) {
|
||||
const ObLogicalOperator *child = NULL;
|
||||
const ObLogicalOperator *pushdown_op = NULL;
|
||||
if (OB_ISNULL(child = get_child(i))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected null", K(ret), K(i), K(child));
|
||||
} else if (OB_FAIL(child->get_pushdown_op(log_op_def::LOG_DISTINCT, pushdown_op))) {
|
||||
LOG_WARN("failed to get push down distinct", K(ret));
|
||||
} else if (NULL == pushdown_op) {
|
||||
// do nothing
|
||||
} else if (OB_UNLIKELY(log_op_def::LOG_DISTINCT != pushdown_op->get_type())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected pushdown op", K(ret), K(pushdown_op->get_type()));
|
||||
} else if (static_cast<const ObLogDistinct*>(pushdown_op)->is_push_down()) {
|
||||
has_push_down = true;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogSet::compute_op_parallel_and_server_info()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
@ -122,6 +122,7 @@ public:
|
||||
virtual int print_used_hint(PlanText &plan_text) override;
|
||||
int get_used_pq_set_hint(const ObPQSetHint *&used_hint);
|
||||
int construct_pq_set_hint(ObPQSetHint &hint);
|
||||
int check_has_push_down(bool &has_push_down);
|
||||
int set_child_ndv(ObIArray<double> &ndv) { return child_ndv_.assign(ndv); }
|
||||
int add_child_ndv(double ndv) { return child_ndv_.push_back(ndv); }
|
||||
virtual int get_card_without_filter(double &card) override;
|
||||
|
334
src/sql/optimizer/ob_log_subplan_filter.cpp
Normal file → Executable file
334
src/sql/optimizer/ob_log_subplan_filter.cpp
Normal file → Executable file
@ -228,9 +228,9 @@ int ObLogSubPlanFilter::do_re_est_cost(EstimateCostInfo ¶m, double &card, do
|
||||
double sel = 1.0;
|
||||
ObSEArray<ObBasicCostInfo, 4> cost_infos;
|
||||
if (OB_ISNULL(get_plan()) || OB_ISNULL(child = get_child(ObLogicalOperator::first_child))
|
||||
|| OB_UNLIKELY(param.need_parallel_ < 1)) {
|
||||
|| OB_UNLIKELY(param.need_parallel_ < 1 || param.need_batch_rescan_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected params", K(ret), K(get_plan()), K(child), K(param.need_parallel_));
|
||||
LOG_WARN("unexpected params", K(ret), K(get_plan()), K(child), K(param));
|
||||
} else if (param.need_row_count_ < 0 || param.need_row_count_ >= child->get_card()) {
|
||||
param.need_row_count_ = -1;
|
||||
} else if (OB_FALSE_IT(get_plan()->get_selectivity_ctx().init_op_ctx(child))) {
|
||||
@ -282,6 +282,8 @@ int ObLogSubPlanFilter::get_re_est_cost_infos(const EstimateCostInfo ¶m,
|
||||
EstimateCostInfo cur_param;
|
||||
double cur_child_card = 0.0;
|
||||
double cur_child_cost = 0.0;
|
||||
bool first_child_is_match_all = false;
|
||||
const common::ObIArray<common::ObAddr> *rescan_left_server_list = param.rescan_left_server_list_;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < get_num_of_child(); ++i) {
|
||||
const ObLogicalOperator *child = get_child(i);
|
||||
cur_param.reset();
|
||||
@ -290,7 +292,19 @@ int ObLogSubPlanFilter::get_re_est_cost_infos(const EstimateCostInfo ¶m,
|
||||
LOG_WARN("set operator i-th child is null", K(ret), K(i));
|
||||
} else if (OB_FAIL(cur_param.assign(param))) {
|
||||
LOG_WARN("failed to assign param", K(ret));
|
||||
} else if (0 != i && OB_FALSE_IT(cur_param.need_row_count_ = -1)) {
|
||||
} else if (0 == i) {
|
||||
if (!child->is_match_all()) {
|
||||
rescan_left_server_list = &child->get_server_list();
|
||||
}
|
||||
} else {
|
||||
cur_param.need_row_count_ = -1;
|
||||
cur_param.need_batch_rescan_ = enable_das_group_rescan()
|
||||
&& !init_plan_idxs_.has_member(i)
|
||||
&& !one_time_idxs_.has_member(i);
|
||||
cur_param.rescan_left_server_list_ = rescan_left_server_list;
|
||||
}
|
||||
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_FAIL(SMART_CALL(get_child(i)->re_est_cost(cur_param, cur_child_card, cur_child_cost)))) {
|
||||
LOG_WARN("failed to re-est child cost", K(ret), K(i));
|
||||
} else if (OB_FAIL(cost_infos.push_back(ObBasicCostInfo(cur_child_card, cur_child_cost,
|
||||
@ -436,168 +450,124 @@ int ObLogSubPlanFilter::compute_sharding_info()
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogSubPlanFilter::check_if_match_das_group_rescan(ObLogicalOperator *root,
|
||||
bool &group_rescan)
|
||||
int ObLogSubPlanFilter::compute_spf_batch_rescan()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_ISNULL(root)) {
|
||||
enable_das_group_rescan_ = false;
|
||||
bool can_batch = false;
|
||||
if (OB_ISNULL(get_plan())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected null", K(ret));
|
||||
} else if (root->is_table_scan()) {
|
||||
bool is_valid = false;
|
||||
ObLogTableScan *tsc = NULL;
|
||||
ObLogPlan *plan = NULL;
|
||||
const AccessPath *ap = NULL;
|
||||
const TableItem *table_item = NULL;
|
||||
if (OB_ISNULL(tsc = static_cast<ObLogTableScan*>(root))
|
||||
// tsc might belong to a different subquery
|
||||
// with its own plan
|
||||
|| OB_ISNULL(plan = tsc->get_plan())
|
||||
|| OB_ISNULL(ap = tsc->get_access_path())
|
||||
|| OB_ISNULL(table_item = plan->get_stmt()->get_table_item_by_id(ap->table_id_))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected null", K(ret));
|
||||
} else if (!tsc->use_das()) {
|
||||
group_rescan = false;
|
||||
} else if (tsc->use_index_merge()) {
|
||||
group_rescan = false;
|
||||
}
|
||||
if (OB_SUCC(ret) && group_rescan) {
|
||||
group_rescan = !(is_virtual_table(ap->ref_table_id_)
|
||||
|| table_item->is_link_table()
|
||||
|| ap->is_cte_path()
|
||||
|| ap->is_function_table_path()
|
||||
|| ap->is_temp_table_path()
|
||||
|| ap->is_json_table_path()
|
||||
|| table_item->for_update_
|
||||
|| !ap->subquery_exprs_.empty()
|
||||
|| EXTERNAL_TABLE == table_item->table_type_
|
||||
);
|
||||
}
|
||||
if (OB_SUCC(ret) && group_rescan) {
|
||||
if (OB_FAIL(ObOptimizerUtil::check_contribute_query_range(root,
|
||||
get_exec_params(),
|
||||
is_valid))) {
|
||||
LOG_WARN("failed to check query range contribution", K(ret));
|
||||
} else if (!is_valid) {
|
||||
group_rescan = false;
|
||||
} else if (tsc->get_scan_direction() != default_asc_direction() && tsc->get_scan_direction() != ObOrderDirection::UNORDERED) {
|
||||
group_rescan = false;
|
||||
} else if (tsc->has_index_scan_filter() && tsc->get_index_back() && tsc->get_is_index_global()) {
|
||||
// For the global index lookup, if there is a pushdown filter when scanning the index,
|
||||
// batch cannot be used.
|
||||
group_rescan = false;
|
||||
} else {/*do nothing*/}
|
||||
}
|
||||
} else if (log_op_def::LOG_SUBPLAN_SCAN == root->get_type()) {
|
||||
if (1 != root->get_num_of_child()) {
|
||||
group_rescan = false;
|
||||
} else if (OB_ISNULL(root->get_child(0))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected null", K(ret));
|
||||
} else if (!root->get_child(0)->is_table_scan()) {
|
||||
group_rescan = false;
|
||||
} else if (OB_FAIL(SMART_CALL(check_if_match_das_group_rescan(root->get_child(0),
|
||||
group_rescan)))) {
|
||||
LOG_WARN("failed to check match das batch rescan", K(ret));
|
||||
}
|
||||
} else {/*do nothing*/}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogSubPlanFilter::set_use_das_batch(ObLogicalOperator* root)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_ISNULL(root)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("invalid input", K(ret));
|
||||
} else if (root->is_table_scan()) {
|
||||
ObLogTableScan *ts = static_cast<ObLogTableScan*>(root);
|
||||
if (!ts->get_range_conditions().empty()) {
|
||||
if (ts->is_text_retrieval_scan()) {
|
||||
ts->set_use_batch(false);
|
||||
} else {
|
||||
ts->set_use_batch(enable_das_group_rescan_);
|
||||
}
|
||||
}
|
||||
} else if (root->get_num_of_child() == 1) {
|
||||
if(OB_FAIL(SMART_CALL(set_use_das_batch(root->get_child(first_child))))) {
|
||||
LOG_WARN("failed to check use das batch", K(ret));
|
||||
}
|
||||
} else { /*do nothing*/ }
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogSubPlanFilter::check_and_set_das_group_rescan()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObSQLSessionInfo *session_info = NULL;
|
||||
ObQueryCtx *query_ctx = NULL;
|
||||
ObLogPlan *plan = NULL;
|
||||
const ObRawExpr *ref_expr = NULL;
|
||||
bool contains_invalid_startup = false;
|
||||
bool has_ref_assign_user_var = false;
|
||||
if (OB_ISNULL(plan = get_plan())
|
||||
|| OB_ISNULL(session_info = plan->get_optimizer_context().get_session_info())
|
||||
|| OB_ISNULL(query_ctx = plan->get_optimizer_context().get_query_ctx())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected null", K(ret), K(plan), K(session_info), K(query_ctx));
|
||||
} else if (!plan->get_optimizer_context().get_enable_spf_batch_rescan()) {
|
||||
enable_das_group_rescan_ = false;
|
||||
LOG_WARN("get unexpected null", K(ret), K(get_plan()));
|
||||
} else if (!get_plan()->get_optimizer_context().enable_spf_batch_rescan()) {
|
||||
/* subplan filter group rescan is disabled */
|
||||
} else if (get_plan()->get_disable_child_batch_rescan()) {
|
||||
/* do nothing */
|
||||
} else if (get_plan()->get_optimizer_context().enable_experimental_batch_rescan()
|
||||
&& OB_FAIL(compute_spf_batch_rescan(can_batch))) {
|
||||
LOG_WARN("failed to compute group rescan", K(ret));
|
||||
} else if (!get_plan()->get_optimizer_context().enable_experimental_batch_rescan()
|
||||
&& OB_FAIL(compute_spf_batch_rescan_compat(can_batch))) {
|
||||
LOG_WARN("failed to compute group rescan compat", K(ret));
|
||||
} else {
|
||||
enable_das_group_rescan_ = plan->get_optimizer_context().get_nlj_batching_enabled();
|
||||
enable_das_group_rescan_ = can_batch;
|
||||
}
|
||||
// check use batch
|
||||
for (int64_t i = 1; OB_SUCC(ret) && enable_das_group_rescan_ && i < get_num_of_child(); i++) {
|
||||
ObLogicalOperator *child = get_child(i);
|
||||
bool contains_invalid_startup = false;
|
||||
bool contains_limit = false;
|
||||
if (OB_ISNULL(child) || OB_ISNULL(child->get_stmt())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected null", K(ret), K(child));
|
||||
} else if (get_initplan_idxs().has_member(i) || get_onetime_idxs().has_member(i)) {
|
||||
enable_das_group_rescan_ = false;
|
||||
} else if (!(child->get_type() == log_op_def::LOG_TABLE_SCAN
|
||||
|| child->get_type() == log_op_def::LOG_SUBPLAN_SCAN)) {
|
||||
enable_das_group_rescan_ = false;
|
||||
} else if (OB_FAIL(check_if_match_das_group_rescan(child, enable_das_group_rescan_))) {
|
||||
LOG_WARN("failed to check match das batch rescan", K(ret));
|
||||
} else if (!enable_das_group_rescan_) {
|
||||
/* do nothing */
|
||||
} else if (OB_FAIL(plan->contains_startup_with_exec_param(child, contains_invalid_startup))) {
|
||||
LOG_WARN("failed to check contains invalid startup", K(ret));
|
||||
} else if (contains_invalid_startup) {
|
||||
enable_das_group_rescan_ = false;
|
||||
} else if (OB_FAIL(child->get_stmt()->has_ref_assign_user_var(has_ref_assign_user_var))) {
|
||||
LOG_WARN("faield to check stmt has assignment ref user var", K(ret));
|
||||
} else if (has_ref_assign_user_var) {
|
||||
enable_das_group_rescan_ = false;
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret) && enable_das_group_rescan_ &&
|
||||
OB_FAIL(ObOptimizerUtil::check_ancestor_node_support_skip_scan(this, enable_das_group_rescan_))) {
|
||||
LOG_WARN("failed to check whether ancestor node support skip read", K(ret));
|
||||
}
|
||||
// check if exec params contain sub_query or rownum
|
||||
for (int64_t i = 0; OB_SUCC(ret) && enable_das_group_rescan_ && i < exec_params_.count(); i++) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogSubPlanFilter::compute_spf_batch_rescan(bool &can_batch)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
can_batch = true;
|
||||
const ObRawExpr *ref_expr = NULL;
|
||||
const ObShardingInfo *sharding = NULL;
|
||||
const ObLogicalOperator *child = NULL;
|
||||
const ObDMLStmt *stmt = NULL;
|
||||
bool has_ref_assign_user_var = false;
|
||||
bool left_allocated_exchange = false;
|
||||
bool right_allocated_exchange = false;
|
||||
bool has_rescan_subquery = false;
|
||||
// check if exec params contain rownum
|
||||
for (int64_t i = 0; OB_SUCC(ret) && can_batch && i < exec_params_.count(); i++) {
|
||||
if (OB_ISNULL(exec_params_.at(i)) || OB_ISNULL(ref_expr = exec_params_.at(i)->get_ref_expr())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected null", K(ret), K(i), K(ref_expr), KPC(exec_params_.at(i)));
|
||||
} else if (ref_expr->has_flag(CNT_SUB_QUERY) || ref_expr->has_flag(CNT_ROWNUM)) {
|
||||
enable_das_group_rescan_ = false;
|
||||
} else {
|
||||
can_batch = !ref_expr->has_flag(CNT_ROWNUM);
|
||||
}
|
||||
}
|
||||
// set use batch
|
||||
for (int64_t i = 1; OB_SUCC(ret) && i < get_num_of_child(); i++) {
|
||||
ObLogicalOperator *child = get_child(i);
|
||||
if (OB_ISNULL(child)) {
|
||||
for (int64_t i = 0; OB_SUCC(ret) && can_batch && i < get_num_of_child(); i++) {
|
||||
if (OB_ISNULL(child = get_child(i)) || OB_ISNULL(sharding = child->get_sharding())
|
||||
|| OB_ISNULL(stmt= child->get_stmt())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected null", K(ret));
|
||||
} else if (OB_FAIL(set_use_das_batch(child))) {
|
||||
LOG_WARN("failed to set use das batch rescan", K(ret));
|
||||
LOG_WARN("get unexpected null", K(ret), K(i), K(sharding), K(stmt));
|
||||
} else if (0 >= i) {
|
||||
left_allocated_exchange = child->is_exchange_allocated();
|
||||
} else if (init_plan_idxs_.has_member(i) || one_time_idxs_.has_member(i)) {
|
||||
can_batch = sharding->is_single();
|
||||
} else if (OB_FAIL(ObOptimizerUtil::check_can_batch_rescan(child, true, can_batch))) {
|
||||
LOG_WARN("failed to check plan can batch rescan", K(ret));
|
||||
} else if (OB_FAIL(stmt->has_ref_assign_user_var(has_ref_assign_user_var))) {
|
||||
LOG_WARN("faield to check stmt has assignment ref user var", K(ret));
|
||||
} else {
|
||||
can_batch &= !has_ref_assign_user_var;
|
||||
has_rescan_subquery = true;
|
||||
right_allocated_exchange |= child->is_exchange_allocated();
|
||||
}
|
||||
}
|
||||
if (OB_FAIL(ret) || !can_batch || !has_rescan_subquery) {
|
||||
can_batch = false;
|
||||
} else if (DistAlgo::DIST_BASIC_METHOD == dist_algo_
|
||||
|| DistAlgo::DIST_NONE_ALL == dist_algo_
|
||||
|| (DistAlgo::DIST_PARTITION_WISE == dist_algo_
|
||||
&& !left_allocated_exchange
|
||||
&& !right_allocated_exchange)) {
|
||||
can_batch = true;
|
||||
} else if (DistAlgo::DIST_PULL_TO_LOCAL == dist_algo_ && !right_allocated_exchange) {
|
||||
can_batch = true;
|
||||
} else {
|
||||
can_batch = false;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogSubPlanFilter::compute_spf_batch_rescan_compat(bool &can_batch)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
can_batch = false;
|
||||
if (!init_plan_idxs_.is_empty() || !one_time_idxs_.is_empty()) {
|
||||
/* disable group rescan for onetime/init plan */
|
||||
} else {
|
||||
can_batch = true;
|
||||
const ObRawExpr *ref_expr = NULL;
|
||||
const ObDMLStmt *stmt = NULL;
|
||||
bool has_ref_assign_user_var = false;
|
||||
// check if exec params contain sub_query/rownum
|
||||
for (int64_t i = 0; OB_SUCC(ret) && can_batch && i < exec_params_.count(); i++) {
|
||||
if (OB_ISNULL(exec_params_.at(i)) || OB_ISNULL(ref_expr = exec_params_.at(i)->get_ref_expr())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected null", K(ret), K(i), K(ref_expr), KPC(exec_params_.at(i)));
|
||||
} else {
|
||||
can_batch = !ref_expr->has_flag(CNT_SUB_QUERY) && !ref_expr->has_flag(CNT_ROWNUM);
|
||||
}
|
||||
}
|
||||
for (int64_t i = 1; OB_SUCC(ret) && can_batch && i < get_num_of_child(); i++) {
|
||||
if (OB_ISNULL(get_child(i)) || OB_ISNULL(stmt= get_child(i)->get_stmt())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected null", K(ret), K(i), K(get_child(i)), K(stmt));
|
||||
} else if (OB_FAIL(ObOptimizerUtil::check_can_batch_rescan_compat(get_child(i),
|
||||
exec_params_,
|
||||
false,
|
||||
can_batch))) {
|
||||
LOG_WARN("failed to check plan can batch rescan", K(ret));
|
||||
} else if (init_plan_idxs_.has_member(i) || one_time_idxs_.has_member(i)) {
|
||||
/* do nothing */
|
||||
} else if (OB_FAIL(stmt->has_ref_assign_user_var(has_ref_assign_user_var))) {
|
||||
LOG_WARN("faield to check stmt has assignment ref user var", K(ret));
|
||||
} else {
|
||||
can_batch &= !has_ref_assign_user_var;
|
||||
}
|
||||
}
|
||||
}
|
||||
LOG_TRACE("spf das batch rescan", K(ret), K(enable_das_group_rescan_));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -929,6 +899,66 @@ int ObLogSubPlanFilter::get_sub_qb_names(ObIArray<ObString> &sub_qb_names)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogSubPlanFilter::check_right_is_local_scan(bool &is_local_scan) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
is_local_scan = true;
|
||||
const ObLogicalOperator *child = NULL;
|
||||
for (int64_t i = 1; is_local_scan && OB_SUCC(ret) && i < get_num_of_child(); i++) {
|
||||
if (init_plan_idxs_.has_member(i) || one_time_idxs_.has_member(i)) {
|
||||
/* do nothing */
|
||||
} else if (OB_ISNULL(child = get_child(i))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected null", K(ret), K(i));
|
||||
} else if (child->is_exchange_allocated() || child->get_contains_das_op()) {
|
||||
is_local_scan = false;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogSubPlanFilter::pre_check_spf_can_px_batch_rescan(bool &can_px_batch_rescan,
|
||||
bool &rescan_contain_match_all) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
can_px_batch_rescan = false;
|
||||
rescan_contain_match_all = false;
|
||||
if (OB_ISNULL(get_plan())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected null", K(ret), K(get_plan()));
|
||||
} else if (1 < get_available_parallel() || 1 < get_parallel()
|
||||
|| get_exec_params().empty()
|
||||
|| !get_plan()->get_optimizer_context().enable_px_batch_rescan()) {
|
||||
/* do nothing */
|
||||
} else {
|
||||
bool find_nested_rescan = false;
|
||||
bool find_rescan_px = false;
|
||||
bool tmp_find_nested_rescan = false;
|
||||
bool tmp_find_rescan_px = false;
|
||||
const ObLogicalOperator *child = NULL;
|
||||
for (int i = 1; !find_nested_rescan && OB_SUCC(ret) && i < get_num_of_child(); ++i) {
|
||||
tmp_find_nested_rescan = false;
|
||||
tmp_find_rescan_px = false;
|
||||
if (OB_ISNULL(child = get_child(i))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected null", K(ret), K(i));
|
||||
} else if (one_time_idxs_.has_member(i)) {
|
||||
/* do nothing */
|
||||
} else if (OB_FAIL(child->pre_check_can_px_batch_rescan(tmp_find_nested_rescan, tmp_find_rescan_px, false))) {
|
||||
LOG_WARN("fail to pre check can px batch rescan", K(ret));
|
||||
} else {
|
||||
find_nested_rescan |= tmp_find_nested_rescan;
|
||||
find_rescan_px |= tmp_find_rescan_px;
|
||||
rescan_contain_match_all |= child->is_match_all() && child->get_contains_das_op();
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
can_px_batch_rescan = !find_nested_rescan && find_rescan_px;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogSubPlanFilter::open_px_resource_analyze(OPEN_PX_RESOURCE_ANALYZE_DECLARE_ARG)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
@ -96,17 +96,14 @@ public:
|
||||
int allocate_granule_post(AllocGIContext &ctx);
|
||||
virtual int compute_one_row_info() override;
|
||||
virtual int compute_sharding_info() override;
|
||||
inline DistAlgo get_distributed_algo() { return dist_algo_; }
|
||||
inline DistAlgo get_distributed_algo() const { return dist_algo_; }
|
||||
inline void set_distributed_algo(const DistAlgo set_dist_algo) { dist_algo_ = set_dist_algo; }
|
||||
|
||||
int add_px_batch_rescan_flag(bool flag) { return enable_px_batch_rescans_.push_back(flag); }
|
||||
common::ObIArray<bool> &get_px_batch_rescans() { return enable_px_batch_rescans_; }
|
||||
|
||||
inline bool enable_das_group_rescan() { return enable_das_group_rescan_; }
|
||||
inline bool enable_das_group_rescan() const { return enable_das_group_rescan_; }
|
||||
inline void set_enable_das_group_rescan(bool flag) { enable_das_group_rescan_ = flag; }
|
||||
int check_and_set_das_group_rescan();
|
||||
int check_if_match_das_group_rescan(ObLogicalOperator *root, bool &group_rescan);
|
||||
int set_use_das_batch(ObLogicalOperator* root);
|
||||
|
||||
int allocate_startup_expr_post() override;
|
||||
|
||||
@ -137,6 +134,11 @@ public:
|
||||
virtual int print_used_hint(PlanText &plan_text) override;
|
||||
virtual int open_px_resource_analyze(OPEN_PX_RESOURCE_ANALYZE_DECLARE_ARG) override;
|
||||
virtual int close_px_resource_analyze(CLOSE_PX_RESOURCE_ANALYZE_DECLARE_ARG) override;
|
||||
int compute_spf_batch_rescan();
|
||||
int compute_spf_batch_rescan(bool &can_batch);
|
||||
int compute_spf_batch_rescan_compat(bool &can_batch);
|
||||
int check_right_is_local_scan(bool &is_local_scan) const;
|
||||
int pre_check_spf_can_px_batch_rescan(bool &can_px_batch_rescan, bool &rescan_contain_match_all) const;
|
||||
private:
|
||||
int extract_exist_style_subquery_exprs(ObRawExpr *expr,
|
||||
ObIArray<ObRawExpr*> &exist_style_exprs);
|
||||
|
@ -136,6 +136,7 @@ int ObLogTableScan::do_re_est_cost(EstimateCostInfo ¶m, double &card, double
|
||||
limit_percent, limit_count, offset_count))) {
|
||||
LOG_WARN("failed to get limit offset value", K(ret));
|
||||
} else {
|
||||
est_cost_info_->rescan_left_server_list_ = param.rescan_left_server_list_;
|
||||
card = get_output_row_count();
|
||||
int64_t part_count = est_cost_info_->index_meta_info_.index_part_count_;
|
||||
double limit_count_double = static_cast<double>(limit_count);
|
||||
@ -169,10 +170,12 @@ int ObLogTableScan::do_re_est_cost(EstimateCostInfo ¶m, double &card, double
|
||||
*est_cost_info_,
|
||||
sample_info_,
|
||||
get_plan()->get_optimizer_context(),
|
||||
access_path_->can_batch_rescan_,
|
||||
card,
|
||||
op_cost))) {
|
||||
LOG_WARN("failed to re estimate cost", K(ret));
|
||||
} else {
|
||||
est_cost_info_->rescan_left_server_list_ = NULL;
|
||||
cost = op_cost;
|
||||
if (0 <= limit_count && param.need_row_count_ == -1) {
|
||||
// full scan with table filters
|
||||
@ -1595,21 +1598,11 @@ int ObLogTableScan::get_plan_item_info(PlanText &plan_text,
|
||||
LOG_WARN("unexpected null param", K(ret));
|
||||
} else if (OB_FAIL(explain_index_selection_info(buf, buf_len, pos))) {
|
||||
LOG_WARN("failed to explain index selection info", K(ret));
|
||||
} else if (OB_FAIL(BUF_PRINTF(NEW_LINE))) {
|
||||
LOG_WARN("BUF_PRINTF fails", K(ret));
|
||||
} else if (OB_FAIL(BUF_PRINTF(OUTPUT_PREFIX))) {
|
||||
LOG_WARN("BUF_PRINTF fails", K(ret));
|
||||
} else if (OB_ISNULL(table_meta =
|
||||
plan->get_basic_table_metas().get_table_meta_by_table_id(table_id_))) {
|
||||
//do nothing
|
||||
} else if (OB_FAIL(BUF_PRINTF("stats info:[version=%ld", table_meta->get_version()))) {
|
||||
LOG_WARN("BUF_PRINTF fails", K(ret));
|
||||
} else if (OB_FAIL(BUF_PRINTF(", is_locked=%d", table_meta->is_stat_locked()))) {
|
||||
LOG_WARN("BUF_PRINTF fails", K(ret));
|
||||
} else if (OB_FAIL(BUF_PRINTF(", is_expired=%d", table_meta->is_opt_stat_expired()))) {
|
||||
LOG_WARN("BUF_PRINTF fails", K(ret));
|
||||
} else if (OB_FAIL(BUF_PRINTF("]"))) {
|
||||
LOG_WARN("BUF_PRINTF fails", K(ret));
|
||||
} else if (OB_FAIL(print_stats_version(*table_meta, buf, buf_len, pos))) {
|
||||
LOG_WARN("failed to print stats version", K(ret));
|
||||
} else if (OB_FAIL(BUF_PRINTF(NEW_LINE))) {
|
||||
LOG_WARN("BUF_PRINTF fails", K(ret));
|
||||
} else if (OB_FAIL(BUF_PRINTF(OUTPUT_PREFIX))) {
|
||||
@ -1732,6 +1725,43 @@ int ObLogTableScan::get_plan_item_info(PlanText &plan_text,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogTableScan::print_stats_version(OptTableMeta &table_meta, char *buf, int64_t &buf_len, int64_t &pos)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObLogPlan *plan = NULL;
|
||||
ObSQLSessionInfo *session_info = NULL;
|
||||
const ObTimeZoneInfo *cur_tz_info = NULL;
|
||||
if (OB_ISNULL(plan = get_plan()) ||
|
||||
OB_ISNULL(session_info = plan->get_optimizer_context().get_session_info()) ||
|
||||
OB_ISNULL(cur_tz_info = session_info->get_tz_info_wrap().get_time_zone_info())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected null param", K(ret));
|
||||
} else {
|
||||
char date[OB_CAST_TO_VARCHAR_MAX_LENGTH] = {0};
|
||||
int64_t date_len = 0;
|
||||
const ObDataTypeCastParams dtc_params(cur_tz_info);
|
||||
ObOTimestampData in_val;
|
||||
in_val.time_us_ = table_meta.get_version();
|
||||
if (OB_FAIL(ObTimeConverter::otimestamp_to_str(in_val, dtc_params, 6, ObTimestampLTZType, date,
|
||||
sizeof(date), date_len))) {
|
||||
LOG_WARN("failed to convert otimestamp to string", K(ret));
|
||||
} else if (OB_FAIL(BUF_PRINTF(NEW_LINE))) {
|
||||
LOG_WARN("BUF_PRINTF fails", K(ret));
|
||||
} else if (OB_FAIL(BUF_PRINTF(OUTPUT_PREFIX))) {
|
||||
LOG_WARN("BUF_PRINTF fails", K(ret));
|
||||
} else if (OB_FAIL(BUF_PRINTF("stats info:[version=%.*s", int32_t(date_len), date))) {
|
||||
LOG_WARN("BUF_PRINTF fails", K(ret));
|
||||
} else if (OB_FAIL(BUF_PRINTF(", is_locked=%d", table_meta.is_stat_locked()))) {
|
||||
LOG_WARN("BUF_PRINTF fails", K(ret));
|
||||
} else if (OB_FAIL(BUF_PRINTF(", is_expired=%d", table_meta.is_opt_stat_expired()))) {
|
||||
LOG_WARN("BUF_PRINTF fails", K(ret));
|
||||
} else if (OB_FAIL(BUF_PRINTF("]"))) {
|
||||
LOG_WARN("BUF_PRINTF fails", K(ret));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogTableScan::print_est_method(ObBaseTableEstMethod method, char *buf, int64_t &buf_len, int64_t &pos)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
@ -516,6 +516,7 @@ public:
|
||||
virtual int inner_replace_op_exprs(ObRawExprReplacer &replacer) override;
|
||||
inline common::ObIArray<bool> &get_filter_before_index_flags() { return filter_before_index_back_; }
|
||||
inline const common::ObIArray<bool> &get_filter_before_index_flags() const { return filter_before_index_back_; }
|
||||
inline const ObRawExpr *get_limit_expr() const { return limit_count_expr_; }
|
||||
inline ObRawExpr *get_limit_expr() { return limit_count_expr_; }
|
||||
inline ObRawExpr *get_offset_expr() { return limit_offset_expr_; }
|
||||
int set_limit_offset(ObRawExpr *limit, ObRawExpr *offset);
|
||||
@ -621,6 +622,7 @@ public:
|
||||
share::schema::ObTableType get_table_type() const { return table_type_; }
|
||||
virtual int get_plan_item_info(PlanText &plan_text,
|
||||
ObSqlPlanItem &plan_item) override;
|
||||
int print_stats_version(OptTableMeta &table_meta, char *buf, int64_t &buf_len, int64_t &pos);
|
||||
int print_est_method(ObBaseTableEstMethod method, char *buf, int64_t &buf_len, int64_t &pos);
|
||||
int get_plan_object_info(PlanText &plan_text,
|
||||
ObSqlPlanItem &plan_item);
|
||||
@ -681,6 +683,7 @@ public:
|
||||
inline bool is_vec_idx_scan() const { return is_index_scan() && vector_index_info_.delta_buffer_tid_ != OB_INVALID_ID; }
|
||||
inline ObVectorIndexInfo &get_vector_index_info() { return vector_index_info_; }
|
||||
inline const ObVectorIndexInfo &get_vector_index_info() const { return vector_index_info_; }
|
||||
inline bool can_batch_rescan() const { return NULL != access_path_ && access_path_->can_batch_rescan_; }
|
||||
|
||||
inline bool das_need_keep_ordering() const { return das_keep_ordering_; }
|
||||
|
||||
|
@ -3087,19 +3087,19 @@ int ObLogicalOperator::check_exchange_rescan(bool &need_rescan)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogicalOperator::check_has_exchange_below(bool &has_exchange) const
|
||||
int ObLogicalOperator::check_has_op_below(const log_op_def::ObLogOpType target_type, bool &has) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
has_exchange = false;
|
||||
if (LOG_EXCHANGE == get_type()) {
|
||||
has_exchange = true;
|
||||
has = false;
|
||||
if (target_type == get_type()) {
|
||||
has = true;
|
||||
} else {
|
||||
ObLogicalOperator *child_op = NULL;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && !has_exchange && i < get_num_of_child(); ++i) {
|
||||
for (int64_t i = 0; OB_SUCC(ret) && !has && i < get_num_of_child(); ++i) {
|
||||
if (OB_ISNULL(child_op = get_child(i))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get_child(i) returns null", K(i), K(ret));
|
||||
} else if (OB_FAIL(SMART_CALL(child_op->check_has_exchange_below(has_exchange)))) {
|
||||
} else if (OB_FAIL(SMART_CALL(child_op->check_has_op_below(target_type, has)))) {
|
||||
LOG_WARN("failed to check if child operator has exchange below", KPC(child_op), K(ret));
|
||||
} else { /* Do nothing */ }
|
||||
}
|
||||
@ -5491,6 +5491,10 @@ int ObLogicalOperator::allocate_partition_join_filter(const ObIArray<JoinFilterI
|
||||
ObLogOperatorFactory &factory = get_plan()->get_log_op_factory();
|
||||
CK(LOG_JOIN == get_type());
|
||||
DistAlgo join_dist_algo = static_cast<ObLogJoin*>(this)->get_join_distributed_method();
|
||||
if (OB_ISNULL(get_plan())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected null plan", K(ret));
|
||||
}
|
||||
for (int i = 0; i < infos.count() && OB_SUCC(ret); ++i) {
|
||||
filter_create = NULL;
|
||||
bool right_has_exchange = false;
|
||||
@ -5543,7 +5547,28 @@ int ObLogicalOperator::allocate_partition_join_filter(const ObIArray<JoinFilterI
|
||||
} else {
|
||||
join_filter_create->set_is_shared_partition_join_filter();
|
||||
}
|
||||
join_filter_create->set_tablet_id_expr(info.calc_part_id_expr_);
|
||||
if (get_plan()->get_optimizer_context().get_query_ctx()->check_opt_compat_version(COMPAT_VERSION_4_3_5) &&
|
||||
DistAlgo::DIST_PARTITION_NONE == join_dist_algo) {
|
||||
ObLogicalOperator* child = get_child(first_child);
|
||||
if (OB_ISNULL(child)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpect null child", K(ret));
|
||||
} else if (OB_ISNULL(child=child->get_child(first_child))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpect null child", K(ret));
|
||||
} else if (OB_ISNULL(child=child->get_child(first_child))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpect null child", K(ret));
|
||||
} else if (LOG_EXCHANGE != child->get_type()) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpect child type", K(ret));
|
||||
} else {
|
||||
ObLogExchange *exch_op = static_cast<ObLogExchange*>(child);
|
||||
join_filter_create->set_tablet_id_expr(exch_op->get_calc_part_id_expr());
|
||||
}
|
||||
} else {
|
||||
join_filter_create->set_tablet_id_expr(info.calc_part_id_expr_);
|
||||
}
|
||||
OZ(join_filter_create->compute_property());
|
||||
OZ(bf_info.init(get_plan()->get_optimizer_context().get_session_info()->get_effective_tenant_id(),
|
||||
filter_id, GCTX.get_server_id(),
|
||||
@ -5862,6 +5887,33 @@ int ObLogicalOperator::find_nested_dis_rescan(bool &find, bool nested)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogicalOperator::pre_check_can_px_batch_rescan(bool &find_nested_rescan,
|
||||
bool &find_rescan_px,
|
||||
bool nested) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (find_nested_rescan) {
|
||||
} else if (LOG_EXCHANGE == get_type()) {
|
||||
const ObLogExchange *op = static_cast<const ObLogExchange *>(this);
|
||||
find_nested_rescan |= nested;
|
||||
find_rescan_px |= !nested && op->is_consumer() && !op->is_task_order();
|
||||
} else {
|
||||
nested = LOG_SUBPLAN_FILTER == get_type() ||
|
||||
(LOG_JOIN == get_type() &&
|
||||
JoinAlgo::NESTED_LOOP_JOIN == static_cast<const ObLogJoin*>(this)->get_join_algo());
|
||||
for (int64_t i = 0; !find_nested_rescan && OB_SUCC(ret) && i < get_num_of_child(); i++) {
|
||||
const ObLogicalOperator *child = NULL;
|
||||
if (OB_ISNULL(child = get_child(i))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected null", K(get_child(i)), K(ret));
|
||||
} else if (OB_FAIL(SMART_CALL(child->pre_check_can_px_batch_rescan(find_nested_rescan, find_rescan_px, nested)))) {
|
||||
LOG_WARN("fail to find px for batch rescan", K(ret));
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogicalOperator::check_subplan_filter_child_exchange_rescanable()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -5982,22 +6034,6 @@ int ObLogicalOperator::find_shuffle_join_filter(bool &find) const
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogicalOperator::has_window_function_below(bool &has_win_func) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
has_win_func = LOG_WINDOW_FUNCTION == get_type();
|
||||
const ObLogicalOperator *child = NULL;
|
||||
for (int64_t i = 0; !has_win_func && OB_SUCC(ret) && i < get_num_of_child(); i++) {
|
||||
if (OB_ISNULL(child = get_child(i))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected null", K(ret), K(child));
|
||||
} else if (OB_FAIL(SMART_CALL(child->has_window_function_below(has_win_func)))) {
|
||||
LOG_WARN("failed to check has window function below", K(ret));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogicalOperator::get_pushdown_op(log_op_def::ObLogOpType op_type, const ObLogicalOperator *&op) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -6171,12 +6207,9 @@ int ObLogicalOperator::pick_out_startup_filters()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObLogPlan *plan = get_plan();
|
||||
const ParamStore *params = NULL;
|
||||
ObOptimizerContext *opt_ctx = NULL;
|
||||
ObArray<ObRawExpr *> filter_exprs;
|
||||
if (OB_ISNULL(plan)
|
||||
|| OB_ISNULL(opt_ctx = &plan->get_optimizer_context())
|
||||
|| OB_ISNULL(params = opt_ctx->get_params())) {
|
||||
if (OB_ISNULL(plan) || OB_ISNULL(opt_ctx = &plan->get_optimizer_context())) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("NULL pointer error", K(plan), K(opt_ctx), K(ret));
|
||||
} else if (OB_FAIL(filter_exprs.assign(filter_exprs_))) {
|
||||
|
@ -1412,9 +1412,9 @@ public:
|
||||
int check_exchange_rescan(bool &need_rescan);
|
||||
|
||||
/**
|
||||
* Check if has exchange below.
|
||||
* Check if has target op below.
|
||||
*/
|
||||
int check_has_exchange_below(bool &has_exchange) const;
|
||||
int check_has_op_below(const log_op_def::ObLogOpType target_type, bool &has) const;
|
||||
/**
|
||||
* Allocate runtime filter operator.
|
||||
*/
|
||||
@ -1655,7 +1655,6 @@ public:
|
||||
ObIArray<ObRawExpr *> &filters_exprs);
|
||||
|
||||
int find_shuffle_join_filter(bool &find) const;
|
||||
int has_window_function_below(bool &has_win_func) const;
|
||||
int get_pushdown_op(log_op_def::ObLogOpType op_type, const ObLogicalOperator *&op) const;
|
||||
|
||||
virtual int get_plan_item_info(PlanText &plan_text,
|
||||
@ -1723,6 +1722,9 @@ public:
|
||||
|
||||
inline ObIArray<double> &get_ambient_card() { return ambient_card_; }
|
||||
|
||||
int pre_check_can_px_batch_rescan(bool &find_nested_rescan,
|
||||
bool &find_rescan_px,
|
||||
bool nested) const;
|
||||
public:
|
||||
ObSEArray<ObLogicalOperator *, 16, common::ModulePageAllocator, true> child_;
|
||||
ObSEArray<ObPCParamEqualInfo, 4, common::ModulePageAllocator, true> equal_param_constraints_;
|
||||
|
@ -210,6 +210,24 @@ double ObOptCostModelParameter::get_px_batch_rescan_per_row_cost(const OptSystem
|
||||
}
|
||||
}
|
||||
|
||||
double ObOptCostModelParameter::get_das_rescan_per_row_rpc_cost(const OptSystemStat& stat) const
|
||||
{
|
||||
if (stat.get_network_speed() <= 0) {
|
||||
return DAS_RESCAN_PER_ROW_RPC_COST;
|
||||
} else {
|
||||
return DAS_RESCAN_PER_ROW_RPC_COST / stat.get_network_speed();
|
||||
}
|
||||
}
|
||||
|
||||
double ObOptCostModelParameter::get_das_batch_rescan_per_row_rpc_cost(const OptSystemStat& stat) const
|
||||
{
|
||||
if (stat.get_network_speed() <= 0) {
|
||||
return DAS_BATCH_RESCAN_PER_ROW_RPC_COST;
|
||||
} else {
|
||||
return DAS_BATCH_RESCAN_PER_ROW_RPC_COST / stat.get_network_speed();
|
||||
}
|
||||
}
|
||||
|
||||
double ObOptCostModelParameter::get_nl_scan_cost(const OptSystemStat& stat) const
|
||||
{
|
||||
if (stat.get_cpu_speed() <= 0) {
|
||||
|
@ -53,6 +53,8 @@ public:
|
||||
const double DEFAULT_NETWORK_TRANS_PER_BYTE_COST,
|
||||
const double DEFAULT_PX_RESCAN_PER_ROW_COST,
|
||||
const double DEFAULT_PX_BATCH_RESCAN_PER_ROW_COST,
|
||||
const double DEFAULT_DAS_RESCAN_PER_ROW_RPC_COST,
|
||||
const double DEFAULT_DAS_BATCH_RESCAN_PER_ROW_RPC_COST,
|
||||
const double DEFAULT_NL_SCAN_COST,
|
||||
const double DEFAULT_BATCH_NL_SCAN_COST,
|
||||
const double DEFAULT_NL_GET_COST,
|
||||
@ -96,6 +98,8 @@ public:
|
||||
NETWORK_TRANS_PER_BYTE_COST(DEFAULT_NETWORK_TRANS_PER_BYTE_COST),
|
||||
PX_RESCAN_PER_ROW_COST(DEFAULT_PX_RESCAN_PER_ROW_COST),
|
||||
PX_BATCH_RESCAN_PER_ROW_COST(DEFAULT_PX_BATCH_RESCAN_PER_ROW_COST),
|
||||
DAS_RESCAN_PER_ROW_RPC_COST(DEFAULT_DAS_RESCAN_PER_ROW_RPC_COST),
|
||||
DAS_BATCH_RESCAN_PER_ROW_RPC_COST(DEFAULT_DAS_BATCH_RESCAN_PER_ROW_RPC_COST),
|
||||
NL_SCAN_COST(DEFAULT_NL_SCAN_COST),
|
||||
BATCH_NL_SCAN_COST(DEFAULT_BATCH_NL_SCAN_COST),
|
||||
NL_GET_COST(DEFAULT_NL_GET_COST),
|
||||
@ -145,6 +149,8 @@ public:
|
||||
double get_network_trans_per_byte_cost(const OptSystemStat& stat) const;
|
||||
double get_px_rescan_per_row_cost(const OptSystemStat& stat) const;
|
||||
double get_px_batch_rescan_per_row_cost(const OptSystemStat& stat) const;
|
||||
double get_das_rescan_per_row_rpc_cost(const OptSystemStat& stat) const;
|
||||
double get_das_batch_rescan_per_row_rpc_cost(const OptSystemStat& stat) const;
|
||||
double get_nl_scan_cost(const OptSystemStat& stat) const;
|
||||
double get_batch_nl_scan_cost(const OptSystemStat& stat) const;
|
||||
double get_nl_get_cost(const OptSystemStat& stat) const;
|
||||
@ -206,6 +212,9 @@ protected:
|
||||
/*additional px-rescan cost*/
|
||||
double PX_RESCAN_PER_ROW_COST;
|
||||
double PX_BATCH_RESCAN_PER_ROW_COST;
|
||||
/*additional das-rescan cost*/
|
||||
double DAS_RESCAN_PER_ROW_RPC_COST;
|
||||
double DAS_BATCH_RESCAN_PER_ROW_RPC_COST;
|
||||
//条件下压nestloop join右表扫一次的代价
|
||||
double NL_SCAN_COST;
|
||||
//条件下压batch nestloop join右表扫一次的代价
|
||||
|
@ -51,16 +51,12 @@ const int64_t ObOptEstCost::MAX_STORAGE_RANGE_ESTIMATION_NUM = 10;
|
||||
|
||||
int ObOptEstCost::cost_nestloop(const ObCostNLJoinInfo &est_cost_info,
|
||||
double &cost,
|
||||
double &filter_selectivity,
|
||||
ObIArray<ObExprSelPair> &all_predicate_sel,
|
||||
const ObOptimizerContext &opt_ctx)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
GET_COST_MODEL();
|
||||
if (OB_FAIL(model->cost_nestloop(est_cost_info,
|
||||
cost,
|
||||
filter_selectivity,
|
||||
all_predicate_sel))) {
|
||||
cost))) {
|
||||
LOG_WARN("failed to est cost for nestloop join", K(ret));
|
||||
}
|
||||
return ret;
|
||||
|
@ -38,8 +38,6 @@ public:
|
||||
|
||||
static int cost_nestloop(const ObCostNLJoinInfo &est_cost_info,
|
||||
double &cost,
|
||||
double &filter_selectivity,
|
||||
common::ObIArray<ObExprSelPair> &all_predicate_sel,
|
||||
const ObOptimizerContext &opt_ctx);
|
||||
|
||||
static int cost_mergejoin(const ObCostMergeJoinInfo &est_cost_info,
|
||||
|
@ -86,8 +86,9 @@ int ObCostTableScanInfo::assign(const ObCostTableScanInfo &est_cost_info)
|
||||
index_meta_info_.assign(est_cost_info.index_meta_info_);
|
||||
is_virtual_table_ = est_cost_info.is_virtual_table_;
|
||||
is_unique_ = est_cost_info.is_unique_;
|
||||
is_inner_path_ = est_cost_info.is_inner_path_;
|
||||
can_use_batch_nlj_ = est_cost_info.can_use_batch_nlj_;
|
||||
is_das_scan_ = est_cost_info.is_das_scan_;
|
||||
is_rescan_ = est_cost_info.is_rescan_;
|
||||
is_batch_rescan_ = est_cost_info.is_batch_rescan_;
|
||||
table_metas_ = est_cost_info.table_metas_;
|
||||
sel_ctx_ = est_cost_info.sel_ctx_;
|
||||
est_method_ = est_cost_info.est_method_;
|
||||
@ -107,6 +108,8 @@ int ObCostTableScanInfo::assign(const ObCostTableScanInfo &est_cost_info)
|
||||
use_column_store_ = est_cost_info.use_column_store_;
|
||||
at_most_one_range_ = est_cost_info.at_most_one_range_;
|
||||
index_back_with_column_store_ = est_cost_info.index_back_with_column_store_;
|
||||
rescan_left_server_list_ = est_cost_info.rescan_left_server_list_;
|
||||
rescan_server_list_ = est_cost_info.rescan_server_list_;
|
||||
limit_rows_ = est_cost_info.limit_rows_;
|
||||
// no need to copy table scan param
|
||||
}
|
||||
@ -208,9 +211,7 @@ double ObIndexMetaInfo::get_micro_block_numbers() const
|
||||
* + qual_cost
|
||||
*/
|
||||
int ObOptEstCostModel::cost_nestloop(const ObCostNLJoinInfo &est_cost_info,
|
||||
double &cost,
|
||||
double &filter_selectivity,
|
||||
ObIArray<ObExprSelPair> &all_predicate_sel)
|
||||
double &cost)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
cost = 0.0;
|
||||
@ -222,60 +223,47 @@ int ObOptEstCostModel::cost_nestloop(const ObCostNLJoinInfo &est_cost_info,
|
||||
double right_rows = est_cost_info.right_rows_;
|
||||
double cart_tuples = left_rows * right_rows; // tuples of Cartesian product
|
||||
double out_tuples = 0.0;
|
||||
filter_selectivity = 0.0;
|
||||
double material_cost = 0.0;
|
||||
//selectivity for equal conds
|
||||
if (OB_FAIL(ObOptSelectivity::calculate_selectivity(*est_cost_info.table_metas_,
|
||||
*est_cost_info.sel_ctx_,
|
||||
est_cost_info.other_join_conditions_,
|
||||
filter_selectivity,
|
||||
all_predicate_sel))) {
|
||||
LOG_WARN("Failed to calculate filter selectivity", K(ret));
|
||||
double join_sel = est_cost_info.other_cond_sel_;
|
||||
if (IS_SEMI_ANTI_JOIN(est_cost_info.join_type_)) {
|
||||
// nested loop join must be left semi/anti join
|
||||
out_tuples = left_rows * join_sel;
|
||||
} else {
|
||||
out_tuples = cart_tuples * filter_selectivity;
|
||||
|
||||
// 再次扫描右表全表的代价。如果不使用物化,就是读取一次右表和本层get_next_row的代价;
|
||||
// 如果物化,则为读取物化后的行的代价。
|
||||
double once_rescan_cost = 0.0;
|
||||
if (est_cost_info.need_mat_) {
|
||||
once_rescan_cost = cost_read_materialized(right_rows);
|
||||
} else {
|
||||
double rescan_cost = 0.0;
|
||||
if (est_cost_info.right_has_px_rescan_) {
|
||||
if (est_cost_info.parallel_ > 1) {
|
||||
rescan_cost = cost_params_.get_px_rescan_per_row_cost(sys_stat_);
|
||||
} else {
|
||||
rescan_cost = cost_params_.get_px_batch_rescan_per_row_cost(sys_stat_);
|
||||
}
|
||||
} else {
|
||||
rescan_cost = cost_params_.get_rescan_cost(sys_stat_);
|
||||
}
|
||||
once_rescan_cost = est_cost_info.right_cost_ + rescan_cost
|
||||
+ right_rows * cost_params_.get_cpu_tuple_cost(sys_stat_);
|
||||
}
|
||||
// total rescan cost
|
||||
if (LEFT_SEMI_JOIN == est_cost_info.join_type_
|
||||
|| LEFT_ANTI_JOIN == est_cost_info.join_type_) {
|
||||
double match_sel = (est_cost_info.anti_or_semi_match_sel_ < OB_DOUBLE_EPSINON) ?
|
||||
OB_DOUBLE_EPSINON : est_cost_info.anti_or_semi_match_sel_;
|
||||
out_tuples = left_rows * match_sel;
|
||||
}
|
||||
cost += left_rows * once_rescan_cost;
|
||||
//qual cost
|
||||
double qual_cost = cost_quals(left_rows * right_rows, est_cost_info.equal_join_conditions_) +
|
||||
cost_quals(left_rows * right_rows, est_cost_info.other_join_conditions_);
|
||||
|
||||
cost += qual_cost;
|
||||
|
||||
double join_cost = cost_params_.get_join_per_row_cost(sys_stat_) * out_tuples;
|
||||
cost += join_cost;
|
||||
|
||||
LOG_TRACE("OPT: [COST NESTLOOP JOIN]",
|
||||
K(cost), K(qual_cost), K(join_cost),K(once_rescan_cost),
|
||||
K(est_cost_info.left_cost_), K(est_cost_info.right_cost_),
|
||||
K(left_rows), K(right_rows), K(est_cost_info.right_width_),
|
||||
K(filter_selectivity), K(cart_tuples), K(material_cost));
|
||||
out_tuples = left_rows * right_rows * join_sel;
|
||||
}
|
||||
|
||||
|
||||
// 再次扫描右表全表的代价。如果不使用物化,就是读取一次右表和本层get_next_row的代价;
|
||||
// 如果物化,则为读取物化后的行的代价。
|
||||
double once_rescan_cost = 0.0;
|
||||
if (est_cost_info.need_mat_) {
|
||||
once_rescan_cost = cost_read_materialized(right_rows);
|
||||
} else {
|
||||
double rescan_cost = 0.0;
|
||||
if (est_cost_info.right_has_px_rescan_) {
|
||||
if (est_cost_info.parallel_ > 1) {
|
||||
rescan_cost = cost_params_.get_px_rescan_per_row_cost(sys_stat_);
|
||||
} else {
|
||||
rescan_cost = cost_params_.get_px_batch_rescan_per_row_cost(sys_stat_);
|
||||
}
|
||||
} else {
|
||||
rescan_cost = cost_params_.get_rescan_cost(sys_stat_);
|
||||
}
|
||||
once_rescan_cost = est_cost_info.right_cost_ + rescan_cost
|
||||
+ right_rows * cost_params_.get_cpu_tuple_cost(sys_stat_);
|
||||
}
|
||||
cost += left_rows * once_rescan_cost;
|
||||
//qual cost
|
||||
double qual_cost = cost_quals(left_rows * right_rows, est_cost_info.equal_join_conditions_) +
|
||||
cost_quals(left_rows * right_rows, est_cost_info.other_join_conditions_);
|
||||
cost += qual_cost;
|
||||
double join_cost = cost_params_.get_join_per_row_cost(sys_stat_) * out_tuples;
|
||||
cost += join_cost;
|
||||
LOG_TRACE("OPT: [COST NESTLOOP JOIN]", K(out_tuples),
|
||||
K(cost), K(qual_cost), K(join_cost),K(once_rescan_cost),
|
||||
K(est_cost_info.left_cost_), K(est_cost_info.right_cost_),
|
||||
K(left_rows), K(right_rows), K(est_cost_info.right_width_),
|
||||
K(join_sel), K(cart_tuples), K(material_cost));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -1392,6 +1380,7 @@ int ObOptEstCostModel::cost_basic_table(const ObCostTableScanInfo &est_cost_info
|
||||
double index_scan_cost = 0;
|
||||
double index_back_cost = 0;
|
||||
double prefix_filter_sel = 1.0;
|
||||
double das_rpc_cost = 0.0;
|
||||
// calc scan one partition cost
|
||||
if (OB_FAIL(cost_index_scan(est_cost_info,
|
||||
row_count_per_part,
|
||||
@ -1405,6 +1394,8 @@ int ObOptEstCostModel::cost_basic_table(const ObCostTableScanInfo &est_cost_info
|
||||
prefix_filter_sel,
|
||||
index_back_cost))) {
|
||||
LOG_WARN("failed to calc index back cost", K(ret));
|
||||
} else if (OB_FAIL(calc_das_rpc_cost(est_cost_info, das_rpc_cost))) {
|
||||
LOG_WARN("failed to calc das rpc cost", K(ret));
|
||||
} else {
|
||||
cost += index_scan_cost;
|
||||
OPT_TRACE_COST_MODEL(KV(cost), "+=", KV(index_scan_cost));
|
||||
@ -1413,7 +1404,10 @@ int ObOptEstCostModel::cost_basic_table(const ObCostTableScanInfo &est_cost_info
|
||||
// calc one parallel scan cost
|
||||
cost *= part_cnt_per_dop;
|
||||
OPT_TRACE_COST_MODEL(KV(cost), "*=", KV(part_cnt_per_dop));
|
||||
LOG_TRACE("OPT:[ESTIMATE FINISH]", K(cost), K(part_cnt_per_dop), K(est_cost_info));
|
||||
// calc das rescan scan rpc cost
|
||||
cost += das_rpc_cost;
|
||||
OPT_TRACE_COST_MODEL(KV(cost), "+=", KV(das_rpc_cost));
|
||||
LOG_TRACE("OPT:[ESTIMATE FINISH]", K(cost), K(part_cnt_per_dop), K(das_rpc_cost), K(est_cost_info));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -1691,6 +1685,67 @@ int ObOptEstCostModel::cost_row_store_index_back(const ObCostTableScanInfo &est_
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int ObOptEstCostModel::calc_das_rpc_cost(const ObCostTableScanInfo &est_cost_info,
|
||||
double &das_rpc_cost)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
das_rpc_cost = 0.0;
|
||||
double remote_rpc_cnt = 0;
|
||||
double local_rpc_cnt = 0;
|
||||
if (OB_ISNULL(est_cost_info.sel_ctx_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected null", K(ret), K(est_cost_info.sel_ctx_));
|
||||
} else if (!est_cost_info.sel_ctx_->get_opt_ctx().enable_425_batch_rescan()) {
|
||||
/* do nothing */
|
||||
} else if (!est_cost_info.is_das_scan_ || !est_cost_info.is_rescan_) {
|
||||
/* do nothing */
|
||||
} else if (OB_FAIL(get_rescan_rpc_cnt(est_cost_info.rescan_left_server_list_,
|
||||
est_cost_info.rescan_server_list_,
|
||||
remote_rpc_cnt,
|
||||
local_rpc_cnt))) {
|
||||
LOG_WARN("failed to get rescan rpc cnt", K(ret));
|
||||
} else if (est_cost_info.is_batch_rescan_) {
|
||||
// ignore local rpc now
|
||||
das_rpc_cost = remote_rpc_cnt * cost_params_.get_das_batch_rescan_per_row_rpc_cost(sys_stat_);
|
||||
} else {
|
||||
das_rpc_cost = remote_rpc_cnt * cost_params_.get_das_rescan_per_row_rpc_cost(sys_stat_);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObOptEstCostModel::get_rescan_rpc_cnt(const ObIArray<common::ObAddr> *left_server_list,
|
||||
const ObIArray<common::ObAddr> *right_server_list,
|
||||
double &remote_rpc_cnt,
|
||||
double &local_rpc_cnt)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
remote_rpc_cnt = 0;
|
||||
local_rpc_cnt = 0;
|
||||
if (OB_ISNULL(right_server_list) || OB_UNLIKELY(right_server_list->empty())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected right server list", K(ret), KPC(right_server_list));
|
||||
} else if (NULL == left_server_list || left_server_list->empty()
|
||||
|| ObShardingInfo::is_shuffled_server_list(*left_server_list)) {
|
||||
remote_rpc_cnt = right_server_list->count();
|
||||
} else if (1 == left_server_list->count() && 1 == right_server_list->count()) {
|
||||
if (left_server_list->at(0) == right_server_list->at(0)) {
|
||||
local_rpc_cnt = 1;
|
||||
} else {
|
||||
remote_rpc_cnt = 1;
|
||||
}
|
||||
} else if (ObOptimizerUtil::is_subset(*left_server_list, *right_server_list)) {
|
||||
remote_rpc_cnt = right_server_list->count() - 1;
|
||||
local_rpc_cnt = 1;
|
||||
} else {
|
||||
remote_rpc_cnt = right_server_list->count();
|
||||
local_rpc_cnt = 0;
|
||||
}
|
||||
LOG_TRACE("OPT:[GET RESCAN RPC CNT]", KPC(left_server_list), KPC(right_server_list),
|
||||
K(remote_rpc_cnt), K(local_rpc_cnt));
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* estimate the network transform and rpc cost for global index,
|
||||
* so far, this cost model should be revised by banliu
|
||||
@ -1828,8 +1883,8 @@ int ObOptEstCostModel::range_get_io_cost(const ObCostTableScanInfo &est_cost_inf
|
||||
}
|
||||
// IO代价,包括读取整个微块及反序列化的代价和每行定位微块的代价
|
||||
double first_block_cost = cost_params_.get_micro_block_rnd_cost(sys_stat_);
|
||||
if (est_cost_info.is_inner_path_) {
|
||||
if (est_cost_info.can_use_batch_nlj_) {
|
||||
if (est_cost_info.is_rescan_) {
|
||||
if (est_cost_info.is_batch_rescan_) {
|
||||
first_block_cost = cost_params_.get_batch_nl_get_cost(sys_stat_);
|
||||
} else {
|
||||
first_block_cost = cost_params_.get_nl_get_cost(sys_stat_);
|
||||
@ -1881,8 +1936,8 @@ int ObOptEstCostModel::range_scan_io_cost(const ObCostTableScanInfo &est_cost_in
|
||||
|
||||
// IO代价,主要包括读取微块、反序列化的代价的代价
|
||||
double first_block_cost = cost_params_.get_micro_block_rnd_cost(sys_stat_);
|
||||
if (!est_cost_info.pushdown_prefix_filters_.empty()) {
|
||||
if (est_cost_info.can_use_batch_nlj_) {
|
||||
if (est_cost_info.is_rescan_) {
|
||||
if (est_cost_info.is_batch_rescan_) {
|
||||
first_block_cost = cost_params_.get_batch_nl_scan_cost(sys_stat_);
|
||||
} else {
|
||||
first_block_cost = cost_params_.get_nl_scan_cost(sys_stat_);
|
||||
|
@ -216,8 +216,9 @@ struct ObCostTableScanInfo
|
||||
index_meta_info_(ref_table_id, index_id),
|
||||
is_virtual_table_(is_virtual_table(ref_table_id)),
|
||||
is_unique_(false),
|
||||
is_inner_path_(false),
|
||||
can_use_batch_nlj_(false),
|
||||
is_das_scan_(false),
|
||||
is_rescan_(false),
|
||||
is_batch_rescan_(false),
|
||||
ranges_(),
|
||||
ss_ranges_(),
|
||||
range_columns_(),
|
||||
@ -244,6 +245,8 @@ struct ObCostTableScanInfo
|
||||
use_column_store_(false),
|
||||
at_most_one_range_(false),
|
||||
index_back_with_column_store_(false),
|
||||
rescan_left_server_list_(NULL),
|
||||
rescan_server_list_(NULL),
|
||||
limit_rows_(-1.0)
|
||||
{ }
|
||||
virtual ~ObCostTableScanInfo()
|
||||
@ -257,7 +260,7 @@ struct ObCostTableScanInfo
|
||||
K_(table_meta_info), K_(index_meta_info),
|
||||
K_(access_column_items),
|
||||
K_(is_virtual_table), K_(is_unique),
|
||||
K_(is_inner_path), K_(can_use_batch_nlj), K_(est_method),
|
||||
K_(is_das_scan), K_(is_rescan), K_(is_batch_rescan), K_(est_method),
|
||||
K_(prefix_filter_sel), K_(pushdown_prefix_filter_sel),
|
||||
K_(postfix_filter_sel), K_(table_filter_sel),
|
||||
K_(ss_prefix_ndv), K_(ss_postfix_range_filters_sel),
|
||||
@ -274,8 +277,9 @@ struct ObCostTableScanInfo
|
||||
ObIndexMetaInfo index_meta_info_; // index related meta info
|
||||
bool is_virtual_table_; // is virtual table
|
||||
bool is_unique_; // whether query range is unique
|
||||
bool is_inner_path_;
|
||||
bool can_use_batch_nlj_;
|
||||
bool is_das_scan_;
|
||||
bool is_rescan_;
|
||||
bool is_batch_rescan_;
|
||||
ObRangesArray ranges_; // all the ranges
|
||||
ObRangesArray ss_ranges_; // skip scan ranges
|
||||
common::ObSEArray<ColumnItem, 4, common::ModulePageAllocator, true> range_columns_; // all the range columns
|
||||
@ -313,6 +317,8 @@ struct ObCostTableScanInfo
|
||||
bool index_back_with_column_store_;
|
||||
common::ObSEArray<ObCostColumnGroupInfo, 4, common::ModulePageAllocator, true> index_scan_column_group_infos_;
|
||||
common::ObSEArray<ObCostColumnGroupInfo, 4, common::ModulePageAllocator, true> index_back_column_group_infos_;
|
||||
const common::ObIArray<common::ObAddr> *rescan_left_server_list_;
|
||||
const common::ObIArray<common::ObAddr> *rescan_server_list_;
|
||||
|
||||
double limit_rows_;
|
||||
private:
|
||||
@ -360,7 +366,7 @@ struct ObCostNLJoinInfo : public ObCostBaseJoinInfo
|
||||
ObCostNLJoinInfo(double left_rows, double left_cost, double left_width,
|
||||
double right_rows, double right_cost, double right_width,
|
||||
ObRelIds left_ids, ObRelIds right_ids, ObJoinType join_type,
|
||||
double anti_or_semi_match_sel,
|
||||
double other_cond_sel,
|
||||
bool with_nl_param,
|
||||
bool need_mat,
|
||||
bool right_has_px_rescan,
|
||||
@ -379,7 +385,7 @@ struct ObCostNLJoinInfo : public ObCostBaseJoinInfo
|
||||
sel_ctx),
|
||||
left_cost_(left_cost),
|
||||
right_cost_(right_cost),
|
||||
anti_or_semi_match_sel_(anti_or_semi_match_sel),
|
||||
other_cond_sel_(other_cond_sel),
|
||||
parallel_(parallel),
|
||||
with_nl_param_(with_nl_param),
|
||||
need_mat_(need_mat),
|
||||
@ -393,7 +399,7 @@ struct ObCostNLJoinInfo : public ObCostBaseJoinInfo
|
||||
K_(equal_join_conditions), K_(other_join_conditions), K_(filters));
|
||||
double left_cost_;
|
||||
double right_cost_;
|
||||
double anti_or_semi_match_sel_;
|
||||
double other_cond_sel_;
|
||||
int64_t parallel_;
|
||||
bool with_nl_param_;
|
||||
bool need_mat_;
|
||||
@ -669,9 +675,7 @@ public:
|
||||
virtual ~ObOptEstCostModel()=default;
|
||||
|
||||
int cost_nestloop(const ObCostNLJoinInfo &est_cost_info,
|
||||
double &cost,
|
||||
double &filter_selectivity,
|
||||
common::ObIArray<ObExprSelPair> &all_predicate_sel);
|
||||
double &cost);
|
||||
|
||||
int cost_mergejoin(const ObCostMergeJoinInfo &est_cost_info,
|
||||
double &cost);
|
||||
@ -879,7 +883,6 @@ protected:
|
||||
double limit_count,
|
||||
double &prefix_filter_sel,
|
||||
double &cost);
|
||||
|
||||
int cost_column_store_index_scan(const ObCostTableScanInfo &est_cost_info,
|
||||
double row_count,
|
||||
double &prefix_filter_sel,
|
||||
@ -898,6 +901,12 @@ protected:
|
||||
double row_count,
|
||||
double limit_count,
|
||||
double &cost);
|
||||
int calc_das_rpc_cost(const ObCostTableScanInfo &est_cost_info,
|
||||
double &das_rpc_cost);
|
||||
int get_rescan_rpc_cnt(const ObIArray<common::ObAddr> *left_server_list,
|
||||
const ObIArray<common::ObAddr> *right_server_list,
|
||||
double &remote_rpc_cnt,
|
||||
double &local_rpc_cnt);
|
||||
// estimate the network transform and rpc cost for global index
|
||||
int cost_global_index_back_with_rp(double row_count,
|
||||
const ObCostTableScanInfo &est_cost_info,
|
||||
|
@ -38,6 +38,8 @@ const static double NORMAL_NETWORK_DESER_PER_BYTE_COST = 0.0094539370039375 * DE
|
||||
const static double NORMAL_NETWORK_TRANS_PER_BYTE_COST = 0.011832508338 * DEFAULT_NETWORK_SPEED;
|
||||
const static double NORMAL_PX_RESCAN_PER_ROW_COST = 398.267410467 * DEFAULT_CPU_SPEED;
|
||||
const static double NORMAL_PX_BATCH_RESCAN_PER_ROW_COST = 49.5841472833 * DEFAULT_CPU_SPEED;
|
||||
const static double NORMAL_DAS_RESCAN_PER_ROW_RPC_COST = 258.3167 * DEFAULT_NETWORK_SPEED;
|
||||
const static double NORMAL_DAS_BATCH_RESCAN_PER_ROW_RPC_COST = 2.1243 * DEFAULT_NETWORK_SPEED;
|
||||
const static double NORMAL_NL_SCAN_COST = 19.2 * DEFAULT_CPU_SPEED;
|
||||
const static double NORMAL_BATCH_NL_SCAN_COST = 16.11 * DEFAULT_CPU_SPEED;
|
||||
const static double NORMAL_NL_GET_COST = 8.24 * DEFAULT_CPU_SPEED;
|
||||
@ -206,6 +208,8 @@ const static ObOptCostModelParameter cost_params_normal(
|
||||
NORMAL_NETWORK_TRANS_PER_BYTE_COST,
|
||||
NORMAL_PX_RESCAN_PER_ROW_COST,
|
||||
NORMAL_PX_BATCH_RESCAN_PER_ROW_COST,
|
||||
NORMAL_DAS_RESCAN_PER_ROW_RPC_COST,
|
||||
NORMAL_DAS_BATCH_RESCAN_PER_ROW_RPC_COST,
|
||||
NORMAL_NL_SCAN_COST,
|
||||
NORMAL_BATCH_NL_SCAN_COST,
|
||||
NORMAL_NL_GET_COST,
|
||||
|
@ -38,6 +38,8 @@ const static double VECTOR_NETWORK_DESER_PER_BYTE_COST = 0.0094539370039375 * DE
|
||||
const static double VECTOR_NETWORK_TRANS_PER_BYTE_COST = 0.011832508338 * DEFAULT_NETWORK_SPEED;
|
||||
const static double VECTOR_PX_RESCAN_PER_ROW_COST = 398.267410467 * DEFAULT_CPU_SPEED;
|
||||
const static double VECTOR_PX_BATCH_RESCAN_PER_ROW_COST = 49.5841472833 * DEFAULT_CPU_SPEED;
|
||||
const static double VECTOR_DAS_RESCAN_PER_ROW_RPC_COST = 258.3167 * DEFAULT_NETWORK_SPEED;
|
||||
const static double VECTOR_DAS_BATCH_RESCAN_PER_ROW_RPC_COST = 2.1243 * DEFAULT_NETWORK_SPEED;
|
||||
const static double VECTOR_NL_SCAN_COST = 17.92 * DEFAULT_CPU_SPEED;
|
||||
const static double VECTOR_BATCH_NL_SCAN_COST = 15.32 * DEFAULT_CPU_SPEED;
|
||||
const static double VECTOR_NL_GET_COST = 6.4 * DEFAULT_CPU_SPEED;
|
||||
@ -201,6 +203,8 @@ const static ObOptCostModelParameter cost_params_vector(
|
||||
VECTOR_NETWORK_TRANS_PER_BYTE_COST,
|
||||
VECTOR_PX_RESCAN_PER_ROW_COST,
|
||||
VECTOR_PX_BATCH_RESCAN_PER_ROW_COST,
|
||||
VECTOR_DAS_RESCAN_PER_ROW_RPC_COST,
|
||||
VECTOR_DAS_BATCH_RESCAN_PER_ROW_RPC_COST,
|
||||
VECTOR_NL_SCAN_COST,
|
||||
VECTOR_BATCH_NL_SCAN_COST,
|
||||
VECTOR_NL_GET_COST,
|
||||
|
@ -146,6 +146,7 @@ int OptColumnMeta::assign(const OptColumnMeta &other)
|
||||
cg_macro_blk_cnt_ = other.cg_macro_blk_cnt_;
|
||||
cg_micro_blk_cnt_ = other.cg_micro_blk_cnt_;
|
||||
cg_skip_rate_ = other.cg_skip_rate_;
|
||||
base_ndv_ = other.base_ndv_;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -164,6 +165,7 @@ void OptColumnMeta::init(const uint64_t column_id,
|
||||
cg_macro_blk_cnt_ = cg_macro_blk_cnt;
|
||||
cg_micro_blk_cnt_ = cg_micro_blk_cnt;
|
||||
cg_skip_rate_ = cg_skip_rate;
|
||||
base_ndv_ = ndv;
|
||||
}
|
||||
|
||||
int OptTableMeta::assign(const OptTableMeta &other)
|
||||
@ -180,6 +182,7 @@ int OptTableMeta::assign(const OptTableMeta &other)
|
||||
base_meta_info_ = other.base_meta_info_;
|
||||
real_rows_ = other.real_rows_;
|
||||
stale_stats_ = other.stale_stats_;
|
||||
base_rows_ = other.base_rows_;
|
||||
|
||||
if (OB_FAIL(all_used_parts_.assign(other.all_used_parts_))) {
|
||||
LOG_WARN("failed to assign all used parts", K(ret));
|
||||
@ -224,6 +227,7 @@ int OptTableMeta::init(const uint64_t table_id,
|
||||
table_partition_info_ = table_partition_info;
|
||||
base_meta_info_ = base_meta_info;
|
||||
real_rows_ = -1.0;
|
||||
base_rows_ = rows;
|
||||
if (OB_FAIL(all_used_parts_.assign(all_used_part_id))) {
|
||||
LOG_WARN("failed to assign all used partition ids", K(ret));
|
||||
} else if (OB_FAIL(all_used_tablets_.assign(all_used_tablets))) {
|
||||
@ -307,6 +311,7 @@ int OptTableMeta::init_column_meta(const OptSelectivityCtx &ctx,
|
||||
col_meta.set_cg_macro_blk_cnt(stat.cg_macro_blk_cnt_);
|
||||
col_meta.set_cg_micro_blk_cnt(stat.cg_micro_blk_cnt_);
|
||||
col_meta.set_cg_skip_rate(stat.cg_skip_rate_);
|
||||
col_meta.set_base_ndv(col_meta.get_ndv());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -487,6 +492,7 @@ int OptTableMetas::add_set_child_stmt_meta_info(const ObSelectStmt *parent_stmt,
|
||||
table_meta->set_table_id(table_id);
|
||||
table_meta->set_ref_table_id(OB_INVALID_ID);
|
||||
table_meta->set_rows(table_rows);
|
||||
table_meta->set_base_rows(table_rows);
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < child_stmt->get_select_item_size(); ++i) {
|
||||
exprs.reset();
|
||||
double ndv = 1;
|
||||
@ -562,7 +568,7 @@ int OptTableMetas::add_generate_table_meta_info(const ObDMLStmt *parent_stmt,
|
||||
ObSEArray<ColumnItem, 8> column_items;
|
||||
ObSEArray<ObRawExpr*, 1> exprs;
|
||||
ObRawExpr *select_expr = NULL;
|
||||
if (OB_ISNULL(parent_stmt) || OB_ISNULL(child_stmt)) {
|
||||
if (OB_ISNULL(parent_stmt) || OB_ISNULL(child_stmt) || OB_ISNULL(child_ctx.get_plan())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get null stmt", K(ret), K(parent_stmt), K(child_stmt));
|
||||
} else if (OB_ISNULL(table_meta = table_metas_.alloc_place_holder())) {
|
||||
@ -572,9 +578,20 @@ int OptTableMetas::add_generate_table_meta_info(const ObDMLStmt *parent_stmt,
|
||||
LOG_WARN("failed to get column items", K(ret));
|
||||
} else {
|
||||
const double table_rows = child_rows < 1.0 ? 1.0 : child_rows;
|
||||
double base_table_rows = table_rows;
|
||||
bool is_child_single_spj = child_stmt->is_spj() && 1 == child_stmt->get_table_size();
|
||||
table_meta->set_table_id(table_id);
|
||||
table_meta->set_ref_table_id(OB_INVALID_ID);
|
||||
table_meta->set_rows(table_rows);
|
||||
if (is_child_single_spj) {
|
||||
const TableItem *table = child_stmt->get_table_item(0);
|
||||
if (OB_NOT_NULL(table)) {
|
||||
base_table_rows = child_table_metas.get_base_rows(table->table_id_);
|
||||
table_meta->set_base_rows(base_table_rows);
|
||||
}
|
||||
} else {
|
||||
table_meta->set_base_rows(table_rows);
|
||||
}
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < column_items.count(); ++i) {
|
||||
const ColumnItem &column_item = column_items.at(i);
|
||||
exprs.reset();
|
||||
@ -629,6 +646,23 @@ int OptTableMetas::add_generate_table_meta_info(const ObDMLStmt *parent_stmt,
|
||||
column_meta->set_max_value(maxobj);
|
||||
column_meta->set_avg_len(avg_len);
|
||||
}
|
||||
if (OB_SUCC(ret) && is_child_single_spj) {
|
||||
double base_ndv = ndv;
|
||||
double nns = 1.0;
|
||||
if (OB_FAIL(ObOptSelectivity::calc_expr_basic_info(child_table_metas,
|
||||
child_ctx,
|
||||
select_expr,
|
||||
NULL,
|
||||
&nns,
|
||||
&base_ndv))) {
|
||||
LOG_WARN("failed to calculate distinct", K(ret));
|
||||
} else {
|
||||
nns = ObOptSelectivity::revise_between_0_1(nns);
|
||||
base_ndv = revise_ndv(base_ndv);
|
||||
column_meta->set_num_null(table_rows * (1 - nns));
|
||||
column_meta->set_base_ndv(base_ndv);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -660,6 +694,7 @@ int OptTableMetas::add_values_table_meta_info(const ObDMLStmt *stmt,
|
||||
table_meta->set_table_id(table_id);
|
||||
table_meta->set_ref_table_id(OB_INVALID_ID);
|
||||
table_meta->set_rows(table_def->row_cnt_);
|
||||
table_meta->set_base_rows(table_def->row_cnt_);
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < column_items.count(); ++i) {
|
||||
const ColumnItem &column_item = column_items.at(i);
|
||||
int64_t idx = column_item.column_id_ - OB_APP_MIN_COLUMN_ID;
|
||||
@ -810,6 +845,16 @@ double OptTableMetas::get_rows(const uint64_t table_id) const
|
||||
return rows;
|
||||
}
|
||||
|
||||
double OptTableMetas::get_base_rows(const uint64_t table_id) const
|
||||
{
|
||||
const OptTableMeta *table_meta = get_table_meta_by_table_id(table_id);
|
||||
double rows = 1.0;
|
||||
if (OB_NOT_NULL(table_meta)) {
|
||||
rows = table_meta->get_base_rows();
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
int ObOptSelectivity::calculate_conditional_selectivity(const OptTableMetas &table_metas,
|
||||
const OptSelectivityCtx &ctx,
|
||||
common::ObIArray<ObRawExpr *> &total_filters,
|
||||
@ -950,12 +995,19 @@ int ObOptSelectivity::calculate_join_selectivity(const OptTableMetas &table_meta
|
||||
const OptSelectivityCtx &ctx,
|
||||
const ObIArray<ObRawExpr*> &predicates,
|
||||
double &selectivity,
|
||||
ObIArray<ObExprSelPair> &all_predicate_sel)
|
||||
ObIArray<ObExprSelPair> &all_predicate_sel,
|
||||
bool is_outerjoin_filter)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
selectivity = 1.0;
|
||||
ObSEArray<ObSelEstimator *, 4> sel_estimators;
|
||||
ObSelEstimatorFactory factory;
|
||||
double reliable_sel_upper_bound = 1.0;
|
||||
double default_complex_sel = 1.0;
|
||||
bool is_complex_join = !is_outerjoin_filter &&
|
||||
(INNER_JOIN == ctx.get_assumption_type() ||
|
||||
IS_OUTER_JOIN(ctx.get_assumption_type()));
|
||||
bool cnt_complex_qual = false;
|
||||
if (OB_ISNULL(ctx.get_session_info())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected null", K(ret));
|
||||
@ -993,9 +1045,49 @@ int ObOptSelectivity::calculate_join_selectivity(const OptTableMetas &table_meta
|
||||
} else if (OB_FAIL(estimator->get_sel(table_metas, ctx, tmp_selectivity, all_predicate_sel))) {
|
||||
LOG_WARN("failed to get sel", K(ret), KPC(estimator));
|
||||
} else {
|
||||
selectivity *= revise_between_0_1(tmp_selectivity);
|
||||
tmp_selectivity = revise_between_0_1(tmp_selectivity);
|
||||
selectivity *= tmp_selectivity;
|
||||
if (estimator->is_complex_join_qual()) {
|
||||
cnt_complex_qual = true;
|
||||
} else {
|
||||
reliable_sel_upper_bound = std::min(reliable_sel_upper_bound, tmp_selectivity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* For complex inner/outer join (which has at least two kinds of quals or one complex join qual),
|
||||
* we assume that each row of the small table matches at least one row of the large table.
|
||||
*/
|
||||
if (OB_SUCC(ret) && ctx.check_opt_compat_version(COMPAT_VERSION_4_2_5, COMPAT_VERSION_4_3_0,
|
||||
COMPAT_VERSION_4_3_5)) {
|
||||
is_complex_join &= sel_estimators.count() > 1 || cnt_complex_qual;
|
||||
if (is_complex_join) {
|
||||
if (LEFT_SEMI_JOIN == ctx.get_join_type()) {
|
||||
default_complex_sel = ctx.get_left_row_count() > 1.0 ?
|
||||
std::min(1.0, ctx.get_right_row_count() / ctx.get_left_row_count()) :
|
||||
1.0;
|
||||
} else if (RIGHT_SEMI_JOIN == ctx.get_join_type()) {
|
||||
default_complex_sel = ctx.get_right_row_count() > 1.0 ?
|
||||
std::min(1.0, ctx.get_left_row_count() / ctx.get_right_row_count()) :
|
||||
1.0;
|
||||
} else {
|
||||
double max_rowcnt = MAX(ctx.get_left_row_count(), ctx.get_right_row_count());
|
||||
default_complex_sel = max_rowcnt > 1.0 ? 1.0 / max_rowcnt : 1.0;
|
||||
}
|
||||
/**
|
||||
* If the join has some normal quals, the selectivity could not be greater than the minimal one
|
||||
* e.g. For join condition `A = B and M = N and X like Y`,
|
||||
* join_selectivity should be less than `A = B` and 'M = N',
|
||||
* but could be greater than `X like Y`.
|
||||
* Because we assume that the selectivity of single equal quals is reliable.
|
||||
*/
|
||||
default_complex_sel = std::min(default_complex_sel, reliable_sel_upper_bound);
|
||||
selectivity = std::max(selectivity, default_complex_sel);
|
||||
}
|
||||
}
|
||||
LOG_TRACE("succeed to calculate join selectivity",
|
||||
K(selectivity), K(is_complex_join), K(default_complex_sel), K(reliable_sel_upper_bound), K(ctx));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -2198,7 +2290,8 @@ int ObOptSelectivity::get_column_basic_info(const OptTableMetas &table_metas,
|
||||
double *ndv_ptr,
|
||||
double *num_null_ptr,
|
||||
double *avg_len_ptr,
|
||||
double *row_count_ptr)
|
||||
double *row_count_ptr,
|
||||
DistinctEstType est_type)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_UNLIKELY(!expr.is_column_ref_expr())) {
|
||||
@ -2212,6 +2305,7 @@ int ObOptSelectivity::get_column_basic_info(const OptTableMetas &table_metas,
|
||||
double avg_len = 0;
|
||||
double row_count = 0;
|
||||
double cur_rowcnt = ctx.get_current_rows();
|
||||
double base_ndv = 0;
|
||||
|
||||
if (OB_FAIL(get_column_basic_from_meta(table_metas,
|
||||
column_expr,
|
||||
@ -2219,36 +2313,48 @@ int ObOptSelectivity::get_column_basic_info(const OptTableMetas &table_metas,
|
||||
row_count,
|
||||
ndv,
|
||||
num_null,
|
||||
avg_len))) {
|
||||
avg_len,
|
||||
base_ndv))) {
|
||||
LOG_WARN("failed to get column basic from meta", K(ret));
|
||||
} else if (need_default && OB_FAIL(get_var_basic_default(row_count, ndv, num_null, avg_len))) {
|
||||
} else if (need_default &&
|
||||
OB_FAIL(get_var_basic_default(row_count, ndv, num_null, avg_len, base_ndv))) {
|
||||
LOG_WARN("failed to get var default info", K(ret));
|
||||
} else {
|
||||
if (num_null > row_count - ndv) {
|
||||
num_null = row_count - ndv > 0 ? row_count - ndv : 0;
|
||||
}
|
||||
if (NULL != ctx.get_ambient_card() &&
|
||||
!ctx.get_ambient_card()->empty() &&
|
||||
ctx.check_opt_compat_version(COMPAT_VERSION_4_2_4, COMPAT_VERSION_4_3_0,
|
||||
COMPAT_VERSION_4_3_3)) {
|
||||
ObSEArray<int64_t, 1> table_idx;
|
||||
if (OB_FAIL(expr.get_relation_ids().to_array(table_idx))) {
|
||||
LOG_WARN("failed to get table idx", K(ret), K(expr));
|
||||
} else if (OB_UNLIKELY(table_idx.count() != 1) ||
|
||||
OB_UNLIKELY(table_idx.at(0) < 1) ||
|
||||
OB_UNLIKELY(table_idx.at(0) >= ctx.get_ambient_card()->count())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected expr relation ids", K(expr), K(table_idx), K(ctx));
|
||||
} else {
|
||||
cur_rowcnt = ctx.get_ambient_card()->at(table_idx.at(0));
|
||||
switch (est_type) {
|
||||
case DistinctEstType::BASE:
|
||||
ndv = base_ndv;
|
||||
cur_rowcnt = -1.0;
|
||||
break;
|
||||
case DistinctEstType::CURRENT: {
|
||||
cur_rowcnt = ctx.get_current_rows();
|
||||
if (NULL != ctx.get_ambient_card() &&
|
||||
!ctx.get_ambient_card()->empty() &&
|
||||
ctx.check_opt_compat_version(COMPAT_VERSION_4_2_4, COMPAT_VERSION_4_3_0,
|
||||
COMPAT_VERSION_4_3_3)) {
|
||||
ObSEArray<int64_t, 1> table_idx;
|
||||
if (OB_FAIL(expr.get_relation_ids().to_array(table_idx))) {
|
||||
LOG_WARN("failed to get table idx", K(ret), K(expr));
|
||||
} else if (OB_UNLIKELY(table_idx.count() != 1) ||
|
||||
OB_UNLIKELY(table_idx.at(0) < 1) ||
|
||||
OB_UNLIKELY(table_idx.at(0) >= ctx.get_ambient_card()->count())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected expr relation ids", K(expr), K(table_idx), K(ctx));
|
||||
} else {
|
||||
cur_rowcnt = ctx.get_ambient_card()->at(table_idx.at(0));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret) && cur_rowcnt > 0.0 && cur_rowcnt < row_count) {
|
||||
ndv = scale_distinct(cur_rowcnt, row_count, ndv);
|
||||
}
|
||||
|
||||
LOG_TRACE("show column basic info", K(row_count), K(cur_rowcnt), K(num_null), K(avg_len), K(ndv));
|
||||
LOG_TRACE("show column basic info",
|
||||
K(row_count), K(cur_rowcnt), K(num_null), K(avg_len), K(ndv), K(est_type));
|
||||
|
||||
// set return
|
||||
if (OB_SUCC(ret)) {
|
||||
@ -2268,7 +2374,8 @@ int ObOptSelectivity::get_column_basic_from_meta(const OptTableMetas &table_meta
|
||||
double &row_count,
|
||||
double &ndv,
|
||||
double &num_null,
|
||||
double &avg_len)
|
||||
double &avg_len,
|
||||
double &base_ndv)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
uint64_t table_id = column_expr.get_table_id();
|
||||
@ -2284,6 +2391,7 @@ int ObOptSelectivity::get_column_basic_from_meta(const OptTableMetas &table_meta
|
||||
ndv = column_meta->get_ndv();
|
||||
num_null = column_meta->get_num_null();
|
||||
avg_len = column_meta->get_avg_len();
|
||||
base_ndv = column_meta->get_base_ndv();
|
||||
}
|
||||
} else {
|
||||
use_default = true;
|
||||
@ -2294,13 +2402,15 @@ int ObOptSelectivity::get_column_basic_from_meta(const OptTableMetas &table_meta
|
||||
int ObOptSelectivity::get_var_basic_default(double &row_count,
|
||||
double &ndv,
|
||||
double &null_num,
|
||||
double &avg_len)
|
||||
double &avg_len,
|
||||
double &base_ndv)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
row_count = 1.0;
|
||||
ndv = 1.0;
|
||||
null_num = static_cast<double>(row_count * EST_DEF_COL_NULL_RATIO);
|
||||
avg_len = DEFAULT_COLUMN_SIZE;
|
||||
base_ndv = 1.0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -2349,10 +2459,9 @@ int ObOptSelectivity::get_compare_value(const OptSelectivityCtx &ctx,
|
||||
LOG_WARN("stmt is null", K(ret));
|
||||
} else if (!calc_expr->is_static_scalar_const_expr()) {
|
||||
can_cmp = false;
|
||||
} else if (OB_FAIL(ObRelationalExprOperator::is_equivalent(col->get_result_type(),
|
||||
col->get_result_type(),
|
||||
calc_expr->get_result_type(),
|
||||
type_safe))) {
|
||||
} else if (OB_FAIL(ObRelationalExprOperator::is_equal_transitive(col->get_result_type(),
|
||||
calc_expr->get_result_type(),
|
||||
type_safe))) {
|
||||
LOG_WARN("failed to check is type safe", K(ret));
|
||||
} else if (!type_safe) {
|
||||
can_cmp = false;
|
||||
@ -2747,11 +2856,13 @@ int ObOptSelectivity::calculate_table_ambient_cardinality(const OptTableMetas &t
|
||||
const OptSelectivityCtx &ctx,
|
||||
const ObRelIds &rel_ids,
|
||||
const double cur_rows,
|
||||
double &table_ambient_card)
|
||||
double &table_ambient_card,
|
||||
DistinctEstType est_type)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (NULL != ctx.get_ambient_card() &&
|
||||
!ctx.get_ambient_card()->empty()) {
|
||||
!ctx.get_ambient_card()->empty() &&
|
||||
DistinctEstType::CURRENT == est_type) {
|
||||
table_ambient_card = 1.0;
|
||||
for (int64_t i = 0; i < ctx.get_ambient_card()->count(); i ++) {
|
||||
if (rel_ids.has_member(i)) {
|
||||
@ -2769,7 +2880,10 @@ int ObOptSelectivity::calculate_table_ambient_cardinality(const OptTableMetas &t
|
||||
LOG_WARN("faile to get table ids", K(ret));
|
||||
}
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < table_ids.count(); i ++) {
|
||||
table_ambient_card *= std::max(1.0, table_metas.get_rows(table_ids.at(i)));
|
||||
table_ambient_card *= std::max(1.0,
|
||||
DistinctEstType::BASE == est_type ?
|
||||
table_metas.get_base_rows(table_ids.at(i)) :
|
||||
table_metas.get_rows(table_ids.at(i)));
|
||||
}
|
||||
}
|
||||
if (cur_rows > 0) {
|
||||
@ -2783,6 +2897,7 @@ int ObOptSelectivity::calculate_distinct_in_single_table(const OptTableMetas &ta
|
||||
const ObRelIds &rel_id,
|
||||
const common::ObIArray<ObRawExpr*>& exprs,
|
||||
const double cur_rows,
|
||||
DistinctEstType est_type,
|
||||
double &rows)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -2795,11 +2910,11 @@ int ObOptSelectivity::calculate_distinct_in_single_table(const OptTableMetas &ta
|
||||
if (OB_UNLIKELY(rel_id.num_members() != 1)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected relation id", K(ret));
|
||||
} else if (OB_FAIL(calculate_table_ambient_cardinality(table_metas, ctx, rel_id, cur_rows, ambient_card))) {
|
||||
} else if (OB_FAIL(calculate_table_ambient_cardinality(table_metas, ctx, rel_id, cur_rows, ambient_card, est_type))) {
|
||||
LOG_WARN("failed to calculate ambient card", K(ret));
|
||||
} else if (OB_FAIL(filter_column_by_equal_set(table_metas, ctx, exprs, filtered_exprs))) {
|
||||
} else if (OB_FAIL(filter_column_by_equal_set(table_metas, ctx, est_type, exprs, filtered_exprs))) {
|
||||
LOG_WARN("failed filter column by equal set", K(ret));
|
||||
} else if (OB_FAIL(calculate_expr_ndv(filtered_exprs, expr_ndv, table_metas, ctx, ambient_card))) {
|
||||
} else if (OB_FAIL(calculate_expr_ndv(filtered_exprs, expr_ndv, table_metas, ctx, ambient_card, est_type))) {
|
||||
LOG_WARN("fail to calculate expr ndv", K(ret));
|
||||
} else if (!ctx.check_opt_compat_version(COMPAT_VERSION_4_2_4, COMPAT_VERSION_4_3_0,
|
||||
COMPAT_VERSION_4_3_3)) {
|
||||
@ -2884,7 +2999,8 @@ int ObOptSelectivity::calculate_distinct(const OptTableMetas &table_metas,
|
||||
const ObIArray<ObRawExpr*>& exprs,
|
||||
const double origin_rows,
|
||||
double &rows,
|
||||
const bool need_refine)
|
||||
const bool need_refine,
|
||||
DistinctEstType est_type)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
rows = 1;
|
||||
@ -2899,7 +3015,7 @@ int ObOptSelectivity::calculate_distinct(const OptTableMetas &table_metas,
|
||||
LOG_WARN("failed to classify_exprs", K(ret));
|
||||
} else if (OB_FAIL(remove_dummy_distinct_exprs(helpers, special_exprs))) {
|
||||
LOG_WARN("failed to remove dummy exprs", K(ret));
|
||||
} else if (OB_FAIL(calculate_expr_ndv(special_exprs, single_ndvs, table_metas, ctx, origin_rows))) {
|
||||
} else if (OB_FAIL(calculate_expr_ndv(special_exprs, single_ndvs, table_metas, ctx, origin_rows, est_type))) {
|
||||
LOG_WARN("fail to calculate expr ndv", K(ret));
|
||||
}
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < helpers.count(); i ++) {
|
||||
@ -2908,7 +3024,7 @@ int ObOptSelectivity::calculate_distinct(const OptTableMetas &table_metas,
|
||||
if (OB_FAIL(remove_dummy_distinct_exprs(helpers, helper.exprs_))) {
|
||||
LOG_WARN("failed to remove dummy exprs", K(ret));
|
||||
} else if (OB_FAIL(calculate_distinct_in_single_table(
|
||||
table_metas, ctx, helper.rel_id_, helper.exprs_, need_refine ? origin_rows : -1, single_table_ndv))) {
|
||||
table_metas, ctx, helper.rel_id_, helper.exprs_, need_refine ? origin_rows : -1, est_type, single_table_ndv))) {
|
||||
LOG_WARN("failed to calculate distinct in single table", K(helper.exprs_));
|
||||
} else if (OB_FAIL(single_ndvs.push_back(single_table_ndv))) {
|
||||
LOG_WARN("failed to push back", K(ret));
|
||||
@ -2939,13 +3055,14 @@ int ObOptSelectivity::calculate_distinct(const OptTableMetas &table_metas,
|
||||
const ObRawExpr& expr,
|
||||
const double origin_rows,
|
||||
double &rows,
|
||||
const bool need_refine)
|
||||
const bool need_refine,
|
||||
DistinctEstType est_type)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObSEArray<ObRawExpr*, 1> expr_array;
|
||||
if (OB_FAIL(expr_array.push_back(const_cast<ObRawExpr*>(&expr)))) {
|
||||
LOG_WARN("failed to push back expr", K(ret));
|
||||
} else if (OB_FAIL(calculate_distinct(table_metas, ctx, expr_array, origin_rows, rows, need_refine))) {
|
||||
} else if (OB_FAIL(calculate_distinct(table_metas, ctx, expr_array, origin_rows, rows, need_refine, est_type))) {
|
||||
LOG_WARN("failed to calculate distinct", K(expr));
|
||||
}
|
||||
return ret;
|
||||
@ -3068,7 +3185,8 @@ int ObOptSelectivity::calculate_expr_ndv(const ObIArray<ObRawExpr*>& exprs,
|
||||
ObIArray<double>& expr_ndv,
|
||||
const OptTableMetas &table_metas,
|
||||
const OptSelectivityCtx &ctx,
|
||||
const double origin_rows)
|
||||
const double origin_rows,
|
||||
DistinctEstType est_type)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < exprs.count(); ++i) {
|
||||
@ -3080,12 +3198,12 @@ int ObOptSelectivity::calculate_expr_ndv(const ObIArray<ObRawExpr*>& exprs,
|
||||
} else if (expr->is_column_ref_expr()) {
|
||||
if (OB_FAIL(check_column_in_current_level_stmt(ctx.get_stmt(), *expr))) {
|
||||
LOG_WARN("failed to check column in current level stmt", K(ret));
|
||||
} else if (OB_FAIL(get_column_basic_info(table_metas, ctx, *expr, &ndv, NULL, NULL, NULL))) {
|
||||
} else if (OB_FAIL(get_column_basic_info(table_metas, ctx, *expr, &ndv, NULL, NULL, NULL, est_type))) {
|
||||
LOG_WARN("failed to get column basic info", K(ret), K(*expr));
|
||||
} else if (OB_FAIL(expr_ndv.push_back(ndv))) {
|
||||
LOG_WARN("failed to push back expr", K(ret), K(ndv));
|
||||
}
|
||||
} else if (OB_FAIL(calculate_special_ndv(table_metas, expr, ctx, ndv, origin_rows))) {
|
||||
} else if (OB_FAIL(calculate_special_ndv(table_metas, expr, ctx, ndv, origin_rows, est_type))) {
|
||||
LOG_WARN("failed to calculate special expr ndv", K(ret), K(ndv));
|
||||
} else if (OB_FAIL(expr_ndv.push_back(ndv))) {
|
||||
LOG_WARN("failed to push back", K(ret), K(ndv));
|
||||
@ -3148,7 +3266,8 @@ int ObOptSelectivity::calculate_special_ndv(const OptTableMetas &table_metas,
|
||||
const ObRawExpr* expr,
|
||||
const OptSelectivityCtx &ctx,
|
||||
double &special_ndv,
|
||||
const double origin_rows)
|
||||
const double origin_rows,
|
||||
DistinctEstType est_type)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const ObRawExpr *param_expr = NULL;
|
||||
@ -3186,7 +3305,8 @@ int ObOptSelectivity::calculate_special_ndv(const OptTableMetas &table_metas,
|
||||
substr_len - ObOptEstCostModel::DEFAULT_FIXED_OBJ_WIDTH,
|
||||
origin_rows,
|
||||
special_ndv,
|
||||
dummy))) {
|
||||
dummy,
|
||||
est_type))) {
|
||||
LOG_WARN("failed to calculate substr ndv", K(ret));
|
||||
}
|
||||
} else if (is_dense_time_expr_type(expr->get_expr_type()) ||
|
||||
@ -3253,7 +3373,9 @@ int ObOptSelectivity::calculate_special_ndv(const OptTableMetas &table_metas,
|
||||
ctx,
|
||||
*param_expr,
|
||||
origin_rows,
|
||||
ndv_upper_bound)))) {
|
||||
ndv_upper_bound,
|
||||
true,
|
||||
est_type)))) {
|
||||
LOG_WARN("failed to calculate distinct", K(ret), KPC(param_expr));
|
||||
} else {
|
||||
special_ndv = std::min(special_ndv, ndv_upper_bound);
|
||||
@ -3401,12 +3523,13 @@ int ObOptSelectivity::calculate_winfunc_ndv(const OptTableMetas &table_metas,
|
||||
// 再把不在 equal set 中的列加入到 filtered_exprs 中,
|
||||
int ObOptSelectivity::filter_column_by_equal_set(const OptTableMetas &table_metas,
|
||||
const OptSelectivityCtx &ctx,
|
||||
DistinctEstType est_type,
|
||||
const ObIArray<ObRawExpr*> &column_exprs,
|
||||
ObIArray<ObRawExpr*> &filtered_exprs)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const EqualSets *equal_sets = ctx.get_equal_sets();
|
||||
if (NULL == equal_sets) {
|
||||
if (NULL == equal_sets || DistinctEstType::CURRENT != est_type) {
|
||||
if (OB_FAIL(append(filtered_exprs, column_exprs))) {
|
||||
LOG_WARN("failed to append filtered exprs", K(ret));
|
||||
}
|
||||
@ -3507,12 +3630,13 @@ int ObOptSelectivity::get_min_ndv_by_equal_set(const OptTableMetas &table_metas,
|
||||
} else if (!is_in) {
|
||||
//do nothing
|
||||
} else if (OB_FAIL(get_column_basic_info(table_metas,
|
||||
ctx,
|
||||
*equal_set->at(k),
|
||||
&tmp_ndv,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL))) {
|
||||
ctx,
|
||||
*equal_set->at(k),
|
||||
&tmp_ndv,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
DistinctEstType::CURRENT))) {
|
||||
LOG_WARN("failed to get var basic sel", K(ret));
|
||||
} else if (OB_INVALID_INDEX_INT64 == min_idx || tmp_ndv < min_ndv) {
|
||||
min_idx = k;
|
||||
@ -3929,7 +4053,7 @@ double ObOptSelectivity::scale_distinct(double selected_rows,
|
||||
*/
|
||||
int ObOptSelectivity::get_join_pred_rows(const ObHistogram &left_hist,
|
||||
const ObHistogram &right_hist,
|
||||
const bool is_semi,
|
||||
const ObJoinType join_type,
|
||||
double &rows)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -3943,8 +4067,10 @@ int ObOptSelectivity::get_join_pred_rows(const ObHistogram &left_hist,
|
||||
LOG_WARN("failed to compare histogram endpoint value", K(ret),
|
||||
K(left_hist.get(lidx).endpoint_value_), K(right_hist.get(ridx).endpoint_value_));
|
||||
} else if (0 == eq_cmp) {
|
||||
if (is_semi) {
|
||||
if (IS_LEFT_SEMI_ANTI_JOIN(join_type)) {
|
||||
rows += left_hist.get(lidx).endpoint_repeat_count_;
|
||||
} else if (IS_RIGHT_SEMI_ANTI_JOIN(join_type)) {
|
||||
rows += right_hist.get(ridx).endpoint_repeat_count_;
|
||||
} else {
|
||||
rows += left_hist.get(lidx).endpoint_repeat_count_ * right_hist.get(ridx).endpoint_repeat_count_;
|
||||
}
|
||||
@ -4295,7 +4421,8 @@ int ObOptSelectivity::calculate_substrb_info(const OptTableMetas &table_metas,
|
||||
const double substrb_len,
|
||||
const double cur_rows,
|
||||
double &substr_ndv,
|
||||
double &nns)
|
||||
double &nns,
|
||||
DistinctEstType est_type)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
double expr_len = 0.0;
|
||||
@ -4316,7 +4443,9 @@ int ObOptSelectivity::calculate_substrb_info(const OptTableMetas &table_metas,
|
||||
ctx,
|
||||
*str_expr,
|
||||
cur_rows,
|
||||
expr_ndv))) {
|
||||
expr_ndv,
|
||||
true,
|
||||
est_type))) {
|
||||
LOG_WARN("failed to calculate distinct", K(ret));
|
||||
} else if (OB_FAIL(calculate_expr_nns(table_metas, ctx, str_expr, nns))) {
|
||||
LOG_WARN("failed to calculate nns", KPC(str_expr));
|
||||
@ -4634,5 +4763,172 @@ int ObOptSelectivity::convert_obj_to_expr_type(const OptSelectivityCtx &ctx,
|
||||
return ret;
|
||||
}
|
||||
|
||||
double ObOptSelectivity::calc_equal_filter_sel(const OptSelectivityCtx &ctx,
|
||||
bool is_same_expr,
|
||||
ObItemType op_type,
|
||||
double left_ndv,
|
||||
double right_ndv,
|
||||
double left_nns,
|
||||
double right_nns)
|
||||
{
|
||||
double selectivity = 0.0;
|
||||
if (is_same_expr) {
|
||||
// same table same column
|
||||
if (T_OP_NSEQ == op_type) {
|
||||
selectivity = 1.0;
|
||||
} else if (T_OP_EQ == op_type) {
|
||||
selectivity = left_nns;
|
||||
} else if (T_OP_NE == op_type) {
|
||||
selectivity = 0.0;
|
||||
}
|
||||
} else if (ctx.check_opt_compat_version(COMPAT_VERSION_4_2_4, COMPAT_VERSION_4_3_0,
|
||||
COMPAT_VERSION_4_3_3)) {
|
||||
double combine_ndv = combine_two_ndvs(ctx.get_current_rows(), left_ndv, right_ndv);
|
||||
combine_ndv = std::max(1.0, combine_ndv);
|
||||
selectivity = std::min(left_ndv, right_ndv) / combine_ndv;
|
||||
if (T_OP_NSEQ == op_type) {
|
||||
selectivity = selectivity * left_nns * right_nns + (1 - left_nns) * (1 - right_nns);
|
||||
} else if (T_OP_EQ == op_type) {
|
||||
selectivity = selectivity * left_nns * right_nns;
|
||||
} else if (T_OP_NE == op_type) {
|
||||
selectivity = std::max(1 - selectivity, 1 / combine_ndv / 2.0) * left_nns * right_nns ;
|
||||
}
|
||||
} else {
|
||||
// deprecated
|
||||
if (T_OP_NSEQ == op_type) {
|
||||
selectivity = left_nns * right_nns / std::max(left_ndv, right_ndv)
|
||||
+ (1 - left_nns) * (1 - right_nns);
|
||||
} else if (T_OP_EQ == op_type) {
|
||||
selectivity = left_nns * right_nns / std::max(left_ndv, right_ndv);
|
||||
} else if (T_OP_NE == op_type) {
|
||||
selectivity = left_nns * right_nns * (1 - 1/std::max(left_ndv, right_ndv));
|
||||
}
|
||||
}
|
||||
|
||||
return selectivity;
|
||||
}
|
||||
|
||||
double ObOptSelectivity::calc_equal_join_sel(const OptSelectivityCtx &ctx,
|
||||
ObItemType op_type,
|
||||
double left_ndv,
|
||||
double right_ndv,
|
||||
double left_nns,
|
||||
double right_nns,
|
||||
double left_base_ndv,
|
||||
double right_base_ndv)
|
||||
|
||||
{
|
||||
double selectivity = 0.0;
|
||||
ObJoinType join_type = ctx.get_join_type();
|
||||
left_base_ndv = MAX(left_ndv, left_base_ndv);
|
||||
right_base_ndv = MAX(right_ndv, right_base_ndv);
|
||||
if (IS_RIGHT_STYLE_JOIN(join_type)) {
|
||||
std::swap(left_ndv, right_ndv);
|
||||
std::swap(left_nns, right_nns);
|
||||
std::swap(left_base_ndv, right_base_ndv);
|
||||
}
|
||||
if (T_OP_NE == op_type && IS_SEMI_ANTI_JOIN(join_type)) {
|
||||
if (right_ndv > 1.0) {
|
||||
// if right ndv > 1.0, then there must exist one value not equal to left value
|
||||
selectivity = left_nns;
|
||||
} else {
|
||||
selectivity = left_nns * std::max(1 - 1 / left_ndv, 1 / left_ndv);
|
||||
}
|
||||
} else if (IS_ANTI_JOIN(ctx.get_join_type()) && ctx.check_opt_compat_version(COMPAT_VERSION_4_2_5, COMPAT_VERSION_4_3_0,
|
||||
COMPAT_VERSION_4_3_5)) {
|
||||
// use base containment assumption only for anti join
|
||||
selectivity = (std::min(left_base_ndv, right_base_ndv) / left_base_ndv) * (right_ndv / right_base_ndv) * left_nns;
|
||||
if (T_OP_NSEQ == op_type && 1 - right_nns > 0) {
|
||||
selectivity += (1 - left_nns);
|
||||
}
|
||||
} else if (IS_SEMI_ANTI_JOIN(join_type)) {
|
||||
selectivity = (std::min(left_ndv, right_ndv) / left_ndv) * left_nns;
|
||||
if (T_OP_NSEQ == op_type && 1 - right_nns > 0) {
|
||||
selectivity += (1 - left_nns);
|
||||
}
|
||||
} else {
|
||||
// inner/outer join
|
||||
double max_ndv = std::max(left_ndv, right_ndv);
|
||||
if (T_OP_NSEQ == op_type) {
|
||||
selectivity = left_nns * right_nns / max_ndv + (1 - left_nns) * (1 - right_nns);
|
||||
} else if (T_OP_EQ == op_type) {
|
||||
selectivity = left_nns * right_nns / max_ndv;
|
||||
} else if (T_OP_NE == op_type) {
|
||||
selectivity = left_nns * right_nns * std::max(1 - 1 / max_ndv, 1 / max_ndv);
|
||||
}
|
||||
}
|
||||
if (IS_ANTI_JOIN(ctx.get_join_type())) {
|
||||
selectivity = std::min(selectivity, 1 - DEFAULT_ANTI_JOIN_SEL);
|
||||
}
|
||||
return selectivity;
|
||||
}
|
||||
|
||||
int ObOptSelectivity::calc_expr_basic_info(const OptTableMetas &table_metas,
|
||||
const OptSelectivityCtx &ctx,
|
||||
const ObRawExpr *expr,
|
||||
double *ndv,
|
||||
double *nns,
|
||||
double *base_ndv)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_ISNULL(expr)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected null expr", K(ret));
|
||||
} else if (OB_FAIL(remove_ignorable_func_for_est_sel(expr))) {
|
||||
LOG_WARN("failed to remove ignorable function", K(ret));
|
||||
} else if (expr->is_column_ref_expr()) {
|
||||
double num_null = 0;
|
||||
double min_ndv = 0;
|
||||
if (OB_FAIL(get_column_ndv_and_nns(table_metas, ctx, *expr, ndv, nns))) {
|
||||
LOG_WARN("failed to get ndv and nns", K(ret));
|
||||
} else if ((OB_NOT_NULL(ndv) || OB_NOT_NULL(nns)) && OB_NOT_NULL(ctx.get_equal_sets())) {
|
||||
bool find = false;
|
||||
ObRawExpr *dummy = NULL;
|
||||
if (OB_FAIL(get_min_ndv_by_equal_set(table_metas,
|
||||
ctx,
|
||||
expr,
|
||||
find,
|
||||
dummy,
|
||||
min_ndv))) {
|
||||
LOG_WARN("failed to find the expr with min ndv", K(ret));
|
||||
} else if (find) {
|
||||
assign_value(min_ndv, ndv);
|
||||
assign_value(1.0, nns);
|
||||
}
|
||||
}
|
||||
if (OB_NOT_NULL(base_ndv)) {
|
||||
if (OB_FAIL(get_column_basic_info(
|
||||
table_metas, ctx, *expr, base_ndv, NULL, NULL, NULL, DistinctEstType::BASE))) {
|
||||
LOG_WARN("failed to get base ndv", K(ret), KPC(expr));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (OB_NOT_NULL(ndv) &&
|
||||
OB_FAIL(calculate_distinct(table_metas,
|
||||
ctx,
|
||||
*expr,
|
||||
ctx.get_current_rows(),
|
||||
*ndv))) {
|
||||
LOG_WARN("Failed to calculate distinct", K(ret));
|
||||
} else if (OB_NOT_NULL(nns) &&
|
||||
OB_FAIL(calculate_expr_nns(table_metas,
|
||||
ctx,
|
||||
expr,
|
||||
*nns))) {
|
||||
LOG_WARN("failed to calculate nns", K(ret));
|
||||
} else if (OB_NOT_NULL(base_ndv) &&
|
||||
OB_FAIL(calculate_distinct(table_metas,
|
||||
ctx,
|
||||
*expr,
|
||||
ctx.get_current_rows(),
|
||||
*base_ndv,
|
||||
false,
|
||||
DistinctEstType::BASE))) {
|
||||
LOG_WARN("Failed to calculate distinct", K(ret));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
}//end of namespace sql
|
||||
}//end of namespace oceanbase
|
||||
|
@ -250,7 +250,7 @@ class OptSelectivityCtx
|
||||
ambient_card_ = NULL;
|
||||
}
|
||||
|
||||
TO_STRING_KV(KP_(stmt), KP_(equal_sets), K_(join_type), KP_(left_rel_ids), KP_(right_rel_ids),
|
||||
TO_STRING_KV(KP_(stmt), KP_(equal_sets), K_(join_type), KPC_(left_rel_ids), KPC_(right_rel_ids),
|
||||
K_(row_count_1), K_(row_count_2), K_(current_rows), KPC_(ambient_card));
|
||||
|
||||
private:
|
||||
@ -293,7 +293,8 @@ public:
|
||||
min_max_inited_(false),
|
||||
cg_macro_blk_cnt_(0),
|
||||
cg_micro_blk_cnt_(0),
|
||||
cg_skip_rate_(1.0)
|
||||
cg_skip_rate_(1.0),
|
||||
base_ndv_(-1.0)
|
||||
{
|
||||
min_val_.set_min_value();
|
||||
max_val_.set_max_value();
|
||||
@ -336,12 +337,15 @@ public:
|
||||
void set_default_meta(double rows)
|
||||
{
|
||||
ndv_ = std::min(rows, std::max(100.0, rows / 100.0));
|
||||
base_ndv_ = ndv_;
|
||||
num_null_ = rows * EST_DEF_COL_NULL_RATIO;
|
||||
}
|
||||
double get_base_ndv() const { return base_ndv_; }
|
||||
void set_base_ndv(double ndv) { base_ndv_ = ndv; }
|
||||
|
||||
TO_STRING_KV(K_(column_id), K_(ndv), K_(num_null), K_(avg_len), K_(hist_scale),
|
||||
K_(min_val), K_(max_val) , K_(min_max_inited), K_(cg_macro_blk_cnt),
|
||||
K_(cg_micro_blk_cnt), K_(cg_skip_rate));
|
||||
K_(cg_micro_blk_cnt), K_(cg_skip_rate), K_(base_ndv));
|
||||
private:
|
||||
uint64_t column_id_;
|
||||
double ndv_;
|
||||
@ -356,6 +360,7 @@ private:
|
||||
int64_t cg_macro_blk_cnt_;
|
||||
int64_t cg_micro_blk_cnt_;
|
||||
double cg_skip_rate_;
|
||||
double base_ndv_;
|
||||
};
|
||||
|
||||
enum OptTableStatType {
|
||||
@ -447,6 +452,8 @@ public:
|
||||
void set_ref_table_id(const uint64_t &ref_table_id) { ref_table_id_ = ref_table_id; }
|
||||
double get_rows() const { return rows_; }
|
||||
void set_rows(const double rows) { rows_ = rows; }
|
||||
double get_base_rows() const { return base_rows_; }
|
||||
void set_base_rows(const double rows) { base_rows_ = rows; }
|
||||
int64_t get_version() const { return last_analyzed_; }
|
||||
void set_version(const int64_t version) { last_analyzed_ = version; }
|
||||
int64_t get_micro_block_count() const { return micro_block_count_; }
|
||||
@ -521,6 +528,8 @@ private:
|
||||
double real_rows_;
|
||||
//mark stat is expired
|
||||
bool stale_stats_;
|
||||
// rows without filters
|
||||
double base_rows_;
|
||||
};
|
||||
|
||||
struct OptSelectivityDSParam {
|
||||
@ -534,6 +543,12 @@ struct OptSelectivityDSParam {
|
||||
ObSEArray<ObRawExpr*, 4, common::ModulePageAllocator, true> quals_;
|
||||
};
|
||||
|
||||
enum class DistinctEstType
|
||||
{
|
||||
BASE, // estimate the ndv without any filters
|
||||
CURRENT, // estimate current ndv according to current rows and ambient cardinality
|
||||
};
|
||||
|
||||
class OptTableMetas
|
||||
{
|
||||
public:
|
||||
@ -598,6 +613,7 @@ public:
|
||||
const ObIArray<OptDynamicExprMeta> &get_dynamic_expr_metas() const { return dynamic_expr_metas_; }
|
||||
|
||||
double get_rows(const uint64_t table_id) const;
|
||||
double get_base_rows(const uint64_t table_id) const;
|
||||
TO_STRING_KV(K_(table_metas), K_(dynamic_expr_metas));
|
||||
private:
|
||||
common::ObSEArray<OptTableMeta, 16, common::ModulePageAllocator, true> table_metas_;
|
||||
@ -671,7 +687,8 @@ public:
|
||||
const OptSelectivityCtx &ctx,
|
||||
const common::ObIArray<ObRawExpr*> &quals,
|
||||
double &selectivity,
|
||||
common::ObIArray<ObExprSelPair> &all_predicate_sel);
|
||||
common::ObIArray<ObExprSelPair> &all_predicate_sel,
|
||||
bool is_outerjoin_filter = false);
|
||||
|
||||
static int calculate_qual_selectivity(const OptTableMetas &table_metas,
|
||||
const OptSelectivityCtx &ctx,
|
||||
@ -704,13 +721,15 @@ public:
|
||||
const OptSelectivityCtx &ctx,
|
||||
const ObRelIds &rel_id,
|
||||
const double cur_rows,
|
||||
double &table_ambient_card);
|
||||
double &table_ambient_card,
|
||||
DistinctEstType est_type);
|
||||
|
||||
static int calculate_distinct_in_single_table(const OptTableMetas &table_metas,
|
||||
const OptSelectivityCtx &ctx,
|
||||
const ObRelIds &rel_ids,
|
||||
const common::ObIArray<ObRawExpr*>& exprs,
|
||||
const double cur_rows,
|
||||
DistinctEstType est_type,
|
||||
double &rows);
|
||||
|
||||
static int remove_dummy_distinct_exprs(ObIArray<OptDistinctHelper> &helpers,
|
||||
@ -726,14 +745,16 @@ public:
|
||||
const common::ObIArray<ObRawExpr*>& exprs,
|
||||
const double origin_rows,
|
||||
double &rows,
|
||||
const bool need_refine = true);
|
||||
const bool need_refine = true,
|
||||
DistinctEstType est_type = DistinctEstType::CURRENT);
|
||||
|
||||
static int calculate_distinct(const OptTableMetas &table_metas,
|
||||
const OptSelectivityCtx &ctx,
|
||||
const ObRawExpr& expr,
|
||||
const double origin_rows,
|
||||
double &rows,
|
||||
const bool need_refine = true);
|
||||
const bool need_refine = true,
|
||||
DistinctEstType est_type = DistinctEstType::CURRENT);
|
||||
|
||||
static double combine_two_ndvs(double ambient_card, double ndv1, double ndv2);
|
||||
|
||||
@ -846,7 +867,8 @@ public:
|
||||
double *ndv_ptr,
|
||||
double *num_null_ptr,
|
||||
double *avg_len_ptr,
|
||||
double *row_count_ptr);
|
||||
double *row_count_ptr,
|
||||
DistinctEstType est_type = DistinctEstType::CURRENT);
|
||||
|
||||
static int get_column_hist_scale(const OptTableMetas &table_metas,
|
||||
const OptSelectivityCtx &ctx,
|
||||
@ -859,12 +881,14 @@ public:
|
||||
double &row_count,
|
||||
double &ndv,
|
||||
double &num_null,
|
||||
double &avg_len);
|
||||
double &avg_len,
|
||||
double &base_ndv);
|
||||
|
||||
static int get_var_basic_default(double &row_count,
|
||||
double &ndv,
|
||||
double &null_num,
|
||||
double &avg_len);
|
||||
double &avg_len,
|
||||
double &base_ndv);
|
||||
|
||||
static int get_histogram_by_column(const OptTableMetas &table_metas,
|
||||
const OptSelectivityCtx &ctx,
|
||||
@ -937,6 +961,7 @@ public:
|
||||
|
||||
static int filter_column_by_equal_set(const OptTableMetas &table_metas,
|
||||
const OptSelectivityCtx &ctx,
|
||||
DistinctEstType est_type,
|
||||
const common::ObIArray<ObRawExpr*> &column_exprs,
|
||||
common::ObIArray<ObRawExpr*> &filtered_exprs);
|
||||
static int filter_one_column_by_equal_set(const OptTableMetas &table_metas,
|
||||
@ -995,7 +1020,7 @@ public:
|
||||
|
||||
static int get_join_pred_rows(const ObHistogram &left_histogram,
|
||||
const ObHistogram &right_histogram,
|
||||
const bool is_semi,
|
||||
const ObJoinType join_type,
|
||||
double &rows);
|
||||
|
||||
static int calc_complex_predicates_selectivity_by_ds(const OptTableMetas &table_metas,
|
||||
@ -1042,7 +1067,8 @@ public:
|
||||
const ObRawExpr* expr,
|
||||
const OptSelectivityCtx &ctx,
|
||||
double &special_ndv,
|
||||
const double origin_rows);
|
||||
const double origin_rows,
|
||||
DistinctEstType est_type);
|
||||
static int calculate_winfunc_ndv(const OptTableMetas &table_meta,
|
||||
const ObRawExpr* expr,
|
||||
const OptSelectivityCtx &ctx,
|
||||
@ -1052,7 +1078,8 @@ public:
|
||||
ObIArray<double>& expr_ndv,
|
||||
const OptTableMetas &table_metas,
|
||||
const OptSelectivityCtx &ctx,
|
||||
const double origin_rows);
|
||||
const double origin_rows,
|
||||
DistinctEstType est_type);
|
||||
static int check_is_special_distinct_expr(const OptSelectivityCtx &ctx,
|
||||
const ObRawExpr *expr,
|
||||
bool &is_special);
|
||||
@ -1086,7 +1113,8 @@ public:
|
||||
const double substrb_len,
|
||||
const double cur_rows,
|
||||
double &ndv,
|
||||
double &nns);
|
||||
double &nns,
|
||||
DistinctEstType est_type = DistinctEstType::CURRENT);
|
||||
static int calculate_expr_nns(const OptTableMetas &table_metas,
|
||||
const OptSelectivityCtx &ctx,
|
||||
const ObRawExpr *expr,
|
||||
@ -1128,6 +1156,30 @@ public:
|
||||
T_FUN_SYS_SECOND == type;
|
||||
}
|
||||
|
||||
static double calc_equal_filter_sel(const OptSelectivityCtx &ctx,
|
||||
bool is_same_expr,
|
||||
ObItemType op_type,
|
||||
double left_ndv,
|
||||
double right_ndv,
|
||||
double left_nns,
|
||||
double right_nns);
|
||||
|
||||
static double calc_equal_join_sel(const OptSelectivityCtx &ctx,
|
||||
ObItemType op_type,
|
||||
double left_ndv,
|
||||
double right_ndv,
|
||||
double left_nns,
|
||||
double right_nns,
|
||||
double left_base_ndv = -1.0,
|
||||
double right_base_ndv = -1.0);
|
||||
|
||||
static int calc_expr_basic_info(const OptTableMetas &table_metas,
|
||||
const OptSelectivityCtx &ctx,
|
||||
const ObRawExpr *expr,
|
||||
double *ndv,
|
||||
double *nns,
|
||||
double *base_ndv);
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObOptSelectivity);
|
||||
};
|
||||
|
@ -564,6 +564,7 @@ int ObOptimizer::extract_opt_ctx_basic_flags(const ObDMLStmt &stmt, ObSQLSession
|
||||
bool storage_estimation_enabled = false;
|
||||
bool has_cursor_expr = false;
|
||||
int64_t link_stmt_count = 0;
|
||||
ObQueryCtx* query_ctx = ctx_.get_query_ctx();
|
||||
bool push_join_pred_into_view_enabled = true;
|
||||
bool partition_wise_plan_enabled = true;
|
||||
bool exists_partition_wise_plan_enabled_hint = false;
|
||||
@ -581,7 +582,10 @@ int ObOptimizer::extract_opt_ctx_basic_flags(const ObDMLStmt &stmt, ObSQLSession
|
||||
bool better_inlist_costing = false;
|
||||
bool enable_spf_batch_rescan = session.is_spf_mlj_group_rescan_enabled();
|
||||
const ObOptParamHint &opt_params = ctx_.get_global_hint().opt_params_;
|
||||
if (OB_FAIL(check_whether_contain_nested_sql(stmt))) {
|
||||
if (OB_ISNULL(query_ctx)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get null query ctx");
|
||||
} else if (OB_FAIL(check_whether_contain_nested_sql(stmt))) {
|
||||
LOG_WARN("check whether contain nested sql failed", K(ret));
|
||||
} else if (OB_FAIL(stmt.check_has_subquery_in_function_table(has_subquery_in_function_table))) {
|
||||
LOG_WARN("failed to check stmt has function table", K(ret));
|
||||
@ -634,6 +638,8 @@ int ObOptimizer::extract_opt_ctx_basic_flags(const ObDMLStmt &stmt, ObSQLSession
|
||||
exists_partition_wise_plan_enabled_hint))) {
|
||||
LOG_WARN("failed to check partition wise plan enabled", K(ret));
|
||||
} else {
|
||||
ctx_.init_batch_rescan_flags(enable_use_batch_nlj, enable_spf_batch_rescan,
|
||||
query_ctx->optimizer_features_enable_version_);
|
||||
ctx_.set_storage_estimation_enabled(storage_estimation_enabled);
|
||||
ctx_.set_serial_set_order(force_serial_set_order);
|
||||
ctx_.set_has_multiple_link_stmt(link_stmt_count > 1);
|
||||
@ -647,8 +653,6 @@ int ObOptimizer::extract_opt_ctx_basic_flags(const ObDMLStmt &stmt, ObSQLSession
|
||||
ctx_.set_optimizer_index_cost_adj(optimizer_index_cost_adj);
|
||||
ctx_.set_is_skip_scan_enabled(is_skip_scan_enable);
|
||||
ctx_.set_enable_better_inlist_costing(better_inlist_costing);
|
||||
ctx_.set_nlj_batching_enabled(enable_use_batch_nlj);
|
||||
ctx_.set_enable_spf_batch_rescan(enable_spf_batch_rescan);
|
||||
ctx_.set_push_join_pred_into_view_enabled(push_join_pred_into_view_enabled);
|
||||
if (!hash_join_enabled
|
||||
&& !optimizer_sortmerge_join_enabled
|
||||
|
@ -219,6 +219,7 @@ ObOptimizerContext(ObSQLSessionInfo *session_info,
|
||||
batch_size_(0),
|
||||
root_stmt_(root_stmt),
|
||||
enable_px_batch_rescan_(-1),
|
||||
batch_rescan_flags_(0),
|
||||
column_usage_infos_(),
|
||||
temp_table_infos_(),
|
||||
exchange_allocated_(false),
|
||||
@ -255,8 +256,6 @@ ObOptimizerContext(ObSQLSessionInfo *session_info,
|
||||
optimizer_index_cost_adj_(0),
|
||||
is_skip_scan_enabled_(false),
|
||||
enable_better_inlist_costing_(false),
|
||||
nlj_batching_enabled_(false),
|
||||
enable_spf_batch_rescan_(false),
|
||||
correlation_type_(ObEstCorrelationType::MAX),
|
||||
use_column_store_replica_(false),
|
||||
push_join_pred_into_view_enabled_(true),
|
||||
@ -425,6 +424,21 @@ ObOptimizerContext(ObSQLSessionInfo *session_info,
|
||||
return enable_px_batch_rescan_;
|
||||
}
|
||||
|
||||
void init_batch_rescan_flags(const bool enable_batch_nlj,
|
||||
const bool enable_batch_spf,
|
||||
const uint64_t opt_version)
|
||||
{
|
||||
enable_nlj_batch_rescan_ = enable_batch_nlj;
|
||||
enable_spf_batch_rescan_ = enable_batch_nlj && enable_batch_spf;
|
||||
// adaptive group-rescan is supported in 4.2.3.0
|
||||
enable_425_batch_rescan_ = GET_MIN_CLUSTER_VERSION() >= COMPAT_VERSION_4_2_3
|
||||
&& (opt_version >= COMPAT_VERSION_4_2_5 || opt_version >= COMPAT_VERSION_4_3_5);
|
||||
}
|
||||
inline bool enable_nlj_batch_rescan() const { return enable_nlj_batch_rescan_; }
|
||||
inline bool enable_spf_batch_rescan() const { return enable_spf_batch_rescan_; }
|
||||
inline bool enable_425_batch_rescan() const { return enable_425_batch_rescan_; }
|
||||
inline bool enable_experimental_batch_rescan() const { return false; }
|
||||
|
||||
int get_px_object_sample_rate()
|
||||
{
|
||||
if (-1 == px_object_sample_rate_) {
|
||||
@ -658,10 +672,6 @@ ObOptimizerContext(ObSQLSessionInfo *session_info,
|
||||
inline void set_is_skip_scan_enabled(bool v) { is_skip_scan_enabled_ = v; }
|
||||
inline bool get_enable_better_inlist_costing() const { return enable_better_inlist_costing_; }
|
||||
inline void set_enable_better_inlist_costing(bool v) { enable_better_inlist_costing_ = v; }
|
||||
inline bool get_nlj_batching_enabled() const { return nlj_batching_enabled_; }
|
||||
inline void set_nlj_batching_enabled(bool v) { nlj_batching_enabled_ = v; }
|
||||
inline bool get_enable_spf_batch_rescan() const { return enable_spf_batch_rescan_; }
|
||||
inline void set_enable_spf_batch_rescan(bool v) { enable_spf_batch_rescan_ = v; }
|
||||
inline bool use_column_store_replica() const { return use_column_store_replica_; }
|
||||
inline void set_use_column_store_replica(bool use) { use_column_store_replica_ = use; }
|
||||
|
||||
@ -707,6 +717,14 @@ private:
|
||||
int64_t batch_size_;
|
||||
ObDMLStmt *root_stmt_;
|
||||
int enable_px_batch_rescan_;
|
||||
union {
|
||||
int64_t batch_rescan_flags_;
|
||||
struct {
|
||||
int64_t enable_nlj_batch_rescan_ : 1; // enable nestloop inner path batch rescan
|
||||
int64_t enable_spf_batch_rescan_ : 1; // enable subplan filter batch rescan
|
||||
int64_t enable_425_batch_rescan_ : 1; // enbale batch rescan behaviors supported in 4.2.5
|
||||
};
|
||||
};
|
||||
common::ObSEArray<ColumnUsageArg, 16, common::ModulePageAllocator, true> column_usage_infos_;
|
||||
common::ObSEArray<ObSqlTempTableInfo*, 1, common::ModulePageAllocator, true> temp_table_infos_;
|
||||
bool exchange_allocated_;
|
||||
@ -761,8 +779,6 @@ private:
|
||||
int64_t optimizer_index_cost_adj_;
|
||||
bool is_skip_scan_enabled_;
|
||||
bool enable_better_inlist_costing_;
|
||||
bool nlj_batching_enabled_;
|
||||
bool enable_spf_batch_rescan_;
|
||||
ObEstCorrelationType correlation_type_;
|
||||
bool use_column_store_replica_;
|
||||
bool push_join_pred_into_view_enabled_;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user