fix some bugs in boundary cases of optimizer stats
This commit is contained in:
@ -1311,12 +1311,13 @@ int ObDynamicSamplingUtils::get_ds_table_param(ObOptimizerContext &ctx,
|
||||
table_meta->get_ref_table_id(),
|
||||
ds_table_param.degree_))) {
|
||||
LOG_WARN("failed to get ds table degree", K(ret));
|
||||
} else if (OB_FAIL(get_dynamic_sampling_max_timeout(ctx, ds_table_param.max_ds_timeout_))) {
|
||||
LOG_WARN("failed to get dynamic sampling max timeout", K(ret));
|
||||
} else {
|
||||
ds_table_param.tenant_id_ = ctx.get_session_info()->get_effective_tenant_id();
|
||||
ds_table_param.table_id_ = table_meta->get_ref_table_id();
|
||||
ds_table_param.ds_level_ = ds_level;
|
||||
ds_table_param.sample_block_cnt_ = sample_block_cnt;
|
||||
ds_table_param.max_ds_timeout_ = get_dynamic_sampling_max_timeout(ctx);
|
||||
ds_table_param.is_virtual_table_ = is_virtual_table(table_meta->get_ref_table_id()) &&
|
||||
!share::is_oracle_mapping_real_virtual_table(table_meta->get_ref_table_id());
|
||||
ds_table_param.db_name_ = table_item->database_name_;
|
||||
@ -1510,18 +1511,24 @@ const ObDSResultItem *ObDynamicSamplingUtils::get_ds_result_item(ObDSResultItemT
|
||||
return item;
|
||||
}
|
||||
|
||||
int64_t ObDynamicSamplingUtils::get_dynamic_sampling_max_timeout(ObOptimizerContext &ctx)
|
||||
int ObDynamicSamplingUtils::get_dynamic_sampling_max_timeout(ObOptimizerContext &ctx,
|
||||
int64_t &max_ds_timeout)
|
||||
{
|
||||
int64_t max_ds_timeout = THIS_WORKER.get_timeout_remain();
|
||||
max_ds_timeout = max_ds_timeout / 10;//default ds time can't exceed 10% of current sql remain timeout
|
||||
omt::ObTenantConfigGuard tenant_config(TENANT_CONF(ctx.get_session_info()->get_effective_tenant_id()));
|
||||
if (tenant_config.is_valid()) {
|
||||
int64_t ds_maximum_time = tenant_config->_optimizer_ads_time_limit * 1000000;
|
||||
if (max_ds_timeout > ds_maximum_time) {//can't exceed the max ds timeout for single table
|
||||
max_ds_timeout = ds_maximum_time;
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_FAIL(THIS_WORKER.check_status())) {
|
||||
LOG_WARN("failed to check status", K(ret));
|
||||
} else {
|
||||
max_ds_timeout = THIS_WORKER.get_timeout_remain();
|
||||
max_ds_timeout = max_ds_timeout / 10;//default ds time can't exceed 10% of current sql remain timeout
|
||||
omt::ObTenantConfigGuard tenant_config(TENANT_CONF(ctx.get_session_info()->get_effective_tenant_id()));
|
||||
if (tenant_config.is_valid()) {
|
||||
int64_t ds_maximum_time = tenant_config->_optimizer_ads_time_limit * 1000000;
|
||||
if (max_ds_timeout > ds_maximum_time) {//can't exceed the max ds timeout for single table
|
||||
max_ds_timeout = ds_maximum_time;
|
||||
}
|
||||
}
|
||||
}
|
||||
return max_ds_timeout;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObDynamicSamplingUtils::add_failed_ds_table_list(const uint64_t table_id,
|
||||
|
||||
@ -368,7 +368,8 @@ public:
|
||||
uint64_t index_id,
|
||||
const ObIArray<ObDSResultItem> &ds_result_items);
|
||||
|
||||
static int64_t get_dynamic_sampling_max_timeout(ObOptimizerContext &ctx);
|
||||
static int get_dynamic_sampling_max_timeout(ObOptimizerContext &ctx,
|
||||
int64_t &max_ds_timeout);
|
||||
|
||||
static int add_failed_ds_table_list(const uint64_t table_id,
|
||||
const common::ObIArray<int64_t> &used_part_id,
|
||||
|
||||
@ -14432,20 +14432,26 @@ int ObLogPlan::perform_gather_stat_replace(ObLogicalOperator *op)
|
||||
}
|
||||
} else {
|
||||
if (NULL != (group_by = dynamic_cast<ObLogGroupBy *>(op))) {
|
||||
if (group_by->get_rollup_exprs().empty() && group_by->get_group_by_exprs().count() == 1) {
|
||||
ObRawExpr* group_by_expr = group_by->get_group_by_exprs().at(0);
|
||||
if (OB_ISNULL(group_by_expr) || OB_ISNULL(stat_partition_id_expr_) || OB_ISNULL(stat_table_scan_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected null", K(group_by_expr), K(stat_partition_id_expr_), K(stat_table_scan_));
|
||||
} else if (T_FUN_SYS_CALC_PARTITION_ID != group_by_expr->get_expr_type()) {
|
||||
// do nothing
|
||||
} else if (OB_FAIL(stat_gather_replacer_.add_replace_expr(group_by_expr,
|
||||
stat_partition_id_expr_))) {
|
||||
LOG_WARN("failed to push back replaced expr", K(ret));
|
||||
} else if (group_by_expr->get_partition_id_calc_type() == CALC_IGNORE_SUB_PART) {
|
||||
stat_table_scan_->set_tablet_id_type(1);
|
||||
} else {
|
||||
stat_table_scan_->set_tablet_id_type(2);
|
||||
if (group_by->get_rollup_exprs().empty() && group_by->get_group_by_exprs().count() > 0) {
|
||||
//bug:
|
||||
bool found_it = false;//expected only one T_FUN_SYS_CALC_PARTITION_ID in gather stats.
|
||||
for (int64_t i = 0; OB_SUCC(ret) && !found_it && i < group_by->get_group_by_exprs().count(); ++i) {
|
||||
ObRawExpr* group_by_expr = group_by->get_group_by_exprs().at(i);
|
||||
if (OB_ISNULL(group_by_expr) || OB_ISNULL(stat_partition_id_expr_) || OB_ISNULL(stat_table_scan_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected null", K(group_by_expr), K(stat_partition_id_expr_), K(stat_table_scan_));
|
||||
} else if (T_FUN_SYS_CALC_PARTITION_ID != group_by_expr->get_expr_type()) {
|
||||
// do nothing
|
||||
} else if (OB_FAIL(stat_gather_replacer_.add_replace_expr(group_by_expr,
|
||||
stat_partition_id_expr_))) {
|
||||
LOG_WARN("failed to push back replaced expr", K(ret));
|
||||
} else if (group_by_expr->get_partition_id_calc_type() == CALC_IGNORE_SUB_PART) {
|
||||
stat_table_scan_->set_tablet_id_type(1);
|
||||
found_it = true;
|
||||
} else {
|
||||
stat_table_scan_->set_tablet_id_type(2);
|
||||
found_it = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user