[CP] Improve query range extraction efficiency when explain sql with single in

This commit is contained in:
obdev
2023-11-15 15:10:17 +00:00
committed by ob-robot
parent d93395d113
commit aa6c3e121a
2 changed files with 18 additions and 6 deletions

View File

@ -276,6 +276,7 @@ int ObQueryRange::preliminary_extract_query_range(const ColumnIArray &range_colu
LOG_WARN("query_range_ctx_ is not inited.", K(ret));
} else {
query_range_ctx_->need_final_extract_ = false;
query_range_ctx_->only_one_expr_ = true;
ObKeyPart *root = NULL;
if (OB_UNLIKELY(NULL == expr_root)) {
//(MIN, MAX), whole range
@ -760,6 +761,7 @@ int ObQueryRange::preliminary_extract_query_range(const ColumnIArray &range_colu
LOG_WARN("add key part range failed", K(ret));
}
} else {
query_range_ctx_->only_one_expr_ = candi_exprs.count() == 1;
for (int64_t i = 0; OB_SUCC(ret) && i < candi_exprs.count(); ++i) {
const ObRawExpr *cur_expr = candi_exprs.at(i);
if (OB_ISNULL(cur_expr)) {
@ -2691,6 +2693,13 @@ int ObQueryRange::pre_extract_single_in_op(const ObOpRawExpr *b_expr,
out_key_part = find_false;
}
query_range_ctx_->cur_expr_is_precise_ = cur_in_is_precise;
int64_t max_pos = -1;
int64_t cur_pos = out_key_part->pos_.offset_;
bool is_strict_equal = false;
if (query_range_ctx_->only_one_expr_ &&
OB_FAIL(is_strict_equal_graph(out_key_part, cur_pos, max_pos, is_strict_equal))) {
LOG_WARN("is trict equal graph failed", K(ret));
} else if (NULL != out_key_part && !is_strict_equal) {
ObKeyPartList key_part_list;
if (OB_FAIL(split_or(out_key_part, key_part_list))) {
LOG_WARN("split temp_result to or_list failed", K(ret));
@ -2699,6 +2708,7 @@ int ObQueryRange::pre_extract_single_in_op(const ObOpRawExpr *b_expr,
}
}
}
}
return ret;
}

View File

@ -99,7 +99,8 @@ private:
expr_constraints_(expr_constraints),
params_(params),
use_in_optimization_(false),
row_in_offsets_()
row_in_offsets_(),
only_one_expr_(false)
{
}
~ObQueryRangeCtx()
@ -121,6 +122,7 @@ private:
ObSEArray<ObKeyPartPos*, 8> key_part_pos_array_;
bool use_in_optimization_;
ObSEArray<int64_t, 4> row_in_offsets_;
bool only_one_expr_;
};
public:
enum ObQueryRangeState