Runtime Filter Optimization
This commit is contained in:
@ -55,6 +55,7 @@ ObExprJoinFilter::ObExprJoinFilterContext::~ObExprJoinFilterContext()
|
||||
}
|
||||
hash_funcs_.reset();
|
||||
cmp_funcs_.reset();
|
||||
cur_row_.reset();
|
||||
}
|
||||
|
||||
void ObExprJoinFilter::ObExprJoinFilterContext::reset_monitor_info()
|
||||
@ -227,6 +228,51 @@ void ObExprJoinFilter::check_need_dynamic_diable_bf(
|
||||
}
|
||||
}
|
||||
|
||||
void ObExprJoinFilter::collect_sample_info_batch(
|
||||
ObExprJoinFilter::ObExprJoinFilterContext &join_filter_ctx,
|
||||
int64_t filter_count, int64_t total_count)
|
||||
{
|
||||
if (!join_filter_ctx.dynamic_disable()) {
|
||||
join_filter_ctx.partial_filter_count_ += filter_count;
|
||||
join_filter_ctx.partial_total_count_ += total_count;
|
||||
}
|
||||
check_need_dynamic_diable_bf_batch(join_filter_ctx);
|
||||
}
|
||||
|
||||
void ObExprJoinFilter::check_need_dynamic_diable_bf_batch(
|
||||
ObExprJoinFilter::ObExprJoinFilterContext &join_filter_ctx)
|
||||
{
|
||||
if (join_filter_ctx.cur_pos_ >= join_filter_ctx.next_check_start_pos_
|
||||
&& join_filter_ctx.need_reset_sample_info_) {
|
||||
join_filter_ctx.partial_total_count_ = 0;
|
||||
join_filter_ctx.partial_filter_count_ = 0;
|
||||
join_filter_ctx.need_reset_sample_info_ = false;
|
||||
if (join_filter_ctx.dynamic_disable()) {
|
||||
join_filter_ctx.dynamic_disable_ = false;
|
||||
}
|
||||
} else if (join_filter_ctx.cur_pos_ >=
|
||||
join_filter_ctx.next_check_start_pos_ + join_filter_ctx.window_size_) {
|
||||
if (join_filter_ctx.partial_total_count_ -
|
||||
join_filter_ctx.partial_filter_count_ <
|
||||
join_filter_ctx.partial_filter_count_) {
|
||||
// partial_filter_count_ / partial_total_count_ > 0.5
|
||||
// The optimizer choose the bloom filter when the filter threshold is larger than 0.6
|
||||
// 0.5 is a acceptable value
|
||||
// if enabled, the slide window not needs to expand
|
||||
join_filter_ctx.window_cnt_ = 0;
|
||||
join_filter_ctx.next_check_start_pos_ = join_filter_ctx.cur_pos_;
|
||||
} else {
|
||||
join_filter_ctx.window_cnt_++;
|
||||
join_filter_ctx.next_check_start_pos_ = join_filter_ctx.cur_pos_ +
|
||||
(join_filter_ctx.window_size_ * join_filter_ctx.window_cnt_);
|
||||
join_filter_ctx.dynamic_disable_ = true;
|
||||
}
|
||||
join_filter_ctx.partial_total_count_ = 0;
|
||||
join_filter_ctx.partial_filter_count_ = 0;
|
||||
join_filter_ctx.need_reset_sample_info_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
int ObExprJoinFilter::eval_bloom_filter(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &res)
|
||||
{
|
||||
return eval_filter_internal(expr, ctx, res);
|
||||
|
||||
@ -40,8 +40,10 @@ public:
|
||||
n_times_(0), ready_ts_(0), next_check_start_pos_(0),
|
||||
window_cnt_(0), window_size_(0),
|
||||
partial_filter_count_(0), partial_total_count_(0),
|
||||
cur_pos_(total_count_), flag_(0)
|
||||
cur_pos_(total_count_), need_reset_sample_info_(false), flag_(0),
|
||||
cur_row_()
|
||||
{
|
||||
cur_row_.set_attr(ObMemAttr(MTL_ID(), "RfCurRow"));
|
||||
need_wait_rf_ = true;
|
||||
is_first_ = true;
|
||||
}
|
||||
@ -70,6 +72,7 @@ public:
|
||||
int64_t partial_filter_count_;
|
||||
int64_t partial_total_count_;
|
||||
int64_t &cur_pos_;
|
||||
bool need_reset_sample_info_; // use for check_need_dynamic_diable_bf_batch
|
||||
union {
|
||||
uint64_t flag_;
|
||||
struct {
|
||||
@ -81,6 +84,7 @@ public:
|
||||
int32_t reserved_:28;
|
||||
};
|
||||
};
|
||||
ObTMArray<ObDatum> cur_row_;
|
||||
};
|
||||
ObExprJoinFilter();
|
||||
explicit ObExprJoinFilter(common::ObIAllocator& alloc);
|
||||
@ -118,6 +122,9 @@ public:
|
||||
static void collect_sample_info(
|
||||
ObExprJoinFilter::ObExprJoinFilterContext *join_filter_ctx,
|
||||
bool is_match);
|
||||
static void collect_sample_info_batch(
|
||||
ObExprJoinFilter::ObExprJoinFilterContext &join_filter_ctx,
|
||||
int64_t filter_count, int64_t total_count);
|
||||
private:
|
||||
static int check_rf_ready(
|
||||
ObExecContext &exec_ctx,
|
||||
@ -125,6 +132,8 @@ private:
|
||||
|
||||
static void check_need_dynamic_diable_bf(
|
||||
ObExprJoinFilter::ObExprJoinFilterContext *join_filter_ctx);
|
||||
static void check_need_dynamic_diable_bf_batch(
|
||||
ObExprJoinFilter::ObExprJoinFilterContext &join_filter_ctx);
|
||||
private:
|
||||
static const int64_t CHECK_TIMES = 127;
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user