add _enable_values_table_folding config param

This commit is contained in:
jingtaoye35 2023-09-15 04:43:48 +00:00 committed by ob-robot
parent cce6e8ff0c
commit 352998fa31
5 changed files with 26 additions and 11 deletions

View File

@ -268,6 +268,9 @@ DEF_INT(_max_malloc_sample_interval, OB_CLUSTER_PARAMETER, "256", "[1, 10000]",
"which is not less than _min_malloc_sample_interval. "
"1 means to sample all malloc, Range: [1, 10000]",
ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE));
DEF_BOOL(_enable_values_table_folding, OB_CLUSTER_PARAMETER, "True",
"whether enable values statement folds self params",
ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE));
//// tenant config
DEF_TIME_WITH_CHECKER(max_stale_time_for_weak_consistency, OB_TENANT_PARAMETER, "5s",
common::ObConfigStaleTimeChecker,

View File

@ -707,6 +707,7 @@ int ObPlanCache::construct_fast_parser_result(common::ObIAllocator &allocator,
bool can_do_batch_insert = false;
ObString first_truncated_sql;
int64_t batch_count = 0;
bool is_insert_values = false;
if (OB_FAIL(ObSqlParameterization::fast_parser(allocator,
fp_ctx,
raw_sql,
@ -717,7 +718,8 @@ int ObPlanCache::construct_fast_parser_result(common::ObIAllocator &allocator,
fp_result,
can_do_batch_insert,
batch_count,
first_truncated_sql))) {
first_truncated_sql,
is_insert_values))) {
LOG_WARN("fail to do insert optimization", K(ret));
} else if (can_do_batch_insert) {
if (OB_FAIL(rebuild_raw_params(allocator,
@ -745,7 +747,8 @@ int ObPlanCache::construct_fast_parser_result(common::ObIAllocator &allocator,
LOG_DEBUG("print new fp_result.pc_key_.name_", K(fp_result.pc_key_.name_));
}
}
} else if (OB_FAIL(ObValuesTableCompression::try_batch_exec_params(allocator, pc_ctx,
} else if (!is_insert_values &&
OB_FAIL(ObValuesTableCompression::try_batch_exec_params(allocator, pc_ctx,
*pc_ctx.sql_ctx_.session_info_, fp_result))) {
LOG_WARN("failed to check fold params valid", K(ret));
}
@ -955,7 +958,8 @@ int ObPlanCache::check_can_do_insert_opt(common::ObIAllocator &allocator,
ObFastParserResult &fp_result,
bool &can_do_batch,
int64_t &batch_count,
ObString &first_truncated_sql)
ObString &first_truncated_sql,
bool &is_insert_values)
{
int ret = OB_SUCCESS;
can_do_batch = false;
@ -1001,6 +1005,10 @@ int ObPlanCache::check_can_do_insert_opt(common::ObIAllocator &allocator,
pc_ctx.insert_batch_opt_info_.update_params_count_ = upd_params_count;
pc_ctx.insert_batch_opt_info_.sql_delta_length_ = delta_length;
}
// if batch_count >= 1, then sql is a insert into .. values ()...;
if (batch_count >= 1) {
is_insert_values = true;
}
}
if (ret != OB_SUCCESS) {

View File

@ -242,7 +242,8 @@ public:
ObFastParserResult &fp_result,
bool &can_do_batch,
int64_t &batch_count,
ObString &first_truncated_sql);
ObString &first_truncated_sql,
bool &is_insert_values);
static int rebuild_raw_params(common::ObIAllocator &allocator,
ObPlanCacheCtx &pc_ctx,
ObFastParserResult &fp_result,

View File

@ -251,14 +251,16 @@ int ObValuesTableCompression::try_batch_exec_params(ObIAllocator &allocator,
ObSEArray<int64_t, 16> raw_pos;
ObPhysicalPlanCtx *phy_ctx = NULL;
uint64_t data_version = 0;
if (OB_FAIL(GET_MIN_DATA_VERSION(session_info.get_effective_tenant_id(), data_version))) {
if (pc_ctx.sql_ctx_.handle_batched_multi_stmt() ||
lib::is_oracle_mode() ||
session_info.is_inner() ||
session_info.get_is_in_retry() ||
fp_result.values_tokens_.empty() ||
!GCONF._enable_values_table_folding) {
/* do nothing */
} else if (OB_FAIL(GET_MIN_DATA_VERSION(session_info.get_effective_tenant_id(), data_version))) {
LOG_WARN("get tenant data version failed", K(ret), K(session_info.get_effective_tenant_id()));
} else if (pc_ctx.sql_ctx_.handle_batched_multi_stmt() ||
lib::is_oracle_mode() ||
session_info.is_inner() ||
session_info.get_is_in_retry() ||
fp_result.values_tokens_.empty() ||
data_version < DATA_VERSION_4_2_1_0 ||
} else if (data_version < DATA_VERSION_4_2_1_0 ||
!is_support_compress_values_table(pc_ctx.raw_sql_)) {
/* do nothing */
} else if (OB_ISNULL(phy_ctx = pc_ctx.exec_ctx_.get_physical_plan_ctx())) {

View File

@ -289,6 +289,7 @@ _enable_system_tenant_memory_limit
_enable_tenant_sql_net_thread
_enable_trace_session_leak
_enable_transaction_internal_routing
_enable_values_table_folding
_endpoint_tenant_mapping
_fast_commit_callback_count
_follower_snapshot_read_retry_duration