Disable group by more than one column pushdown temporarily

This commit is contained in:
XIAO-HOU 2024-09-03 17:12:31 +00:00 committed by ob-robot
parent 0cd88a4196
commit 31d0d37870
3 changed files with 55 additions and 4 deletions

View File

@ -899,8 +899,8 @@ int ObGroupByCellVec::init(const ObTableAccessParam &param, const ObTableAccessC
null_datum.set_null();
for (int64_t i = 0; OB_SUCC(ret) && i < param.output_exprs_->count(); ++i) {
if (T_PSEUDO_GROUP_ID == param.output_exprs_->at(i)->type_) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("Unexpected group idx expr", K(ret), KPC(param.output_exprs_->at(i)));
LOG_TRACE("Group by pushdown in batch nlj", K(ret));
continue;
} else if (nullptr == param.output_sel_mask_ || param.output_sel_mask_->at(i)) {
int32_t col_offset = param.iter_param_.out_cols_project_->at(i);
sql::ObExpr *expr = param.output_exprs_->at(i);

View File

@ -40,7 +40,8 @@ ObVectorStore::ObVectorStore(
default_row_(),
group_by_cell_(nullptr),
iter_param_(nullptr),
skip_bit_(skip_bit)
skip_bit_(skip_bit),
need_check_group_by_(false)
{}
ObVectorStore::~ObVectorStore()
@ -65,6 +66,7 @@ void ObVectorStore::reset()
context_.stmt_allocator_->free(group_by_cell_);
group_by_cell_ = nullptr;
}
need_check_group_by_ = false;
}
int ObVectorStore::init(const ObTableAccessParam &param, common::hash::ObHashSet<int32_t> *agg_col_mask)
@ -192,6 +194,50 @@ int ObVectorStore::check_agg_mask(
return ret;
}
int ObVectorStore::check_need_group_by(const ObTableAccessParam &param)
{
int ret = OB_SUCCESS;
if (OB_UNLIKELY(nullptr == param.output_exprs_ ||
nullptr == param.iter_param_.group_by_cols_project_ ||
0 == param.iter_param_.group_by_cols_project_->count())) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("Invalid argument", K(ret), K(param));
} else {
need_check_group_by_ = true;
ObMemAttr attr(MTL_ID(), common::ObModIds::OB_HASH_BUCKET);
common::hash::ObHashSet<int32_t> col_offset_set;
const int32_t group_by_col_offset = param.iter_param_.group_by_cols_project_->at(0);
const int32_t agg_expr_cnt = nullptr == param.aggregate_exprs_ ? 0 : param.aggregate_exprs_->count();
if (OB_FAIL(col_offset_set.create((agg_expr_cnt + 1) * 2, attr))) {
LOG_WARN("Failed to create column offset set", K(ret), K(agg_expr_cnt));
}
for (int64_t i = 0; OB_SUCC(ret) && i < agg_expr_cnt; ++i) {
int32_t col_offset = param.iter_param_.agg_cols_project_->at(i);
if (OB_FAIL(col_offset_set.set_refactored(col_offset, 0/*deduplicated*/))) {
LOG_WARN("Failed to add column offset", K(ret), K(i), K(col_offset));
}
}
for (int64_t i = 0; OB_SUCC(ret) && need_check_group_by_ && i < param.output_exprs_->count(); ++i) {
if (T_PSEUDO_GROUP_ID == param.output_exprs_->at(i)->type_) {
} else if (nullptr == param.output_sel_mask_ || param.output_sel_mask_->at(i)) {
int32_t col_offset = param.iter_param_.out_cols_project_->at(i);
if (group_by_col_offset != col_offset) {
ret = col_offset_set.exist_refactored(col_offset);
if (OB_HASH_EXIST == ret) {
ret = OB_SUCCESS;
} else if (OB_HASH_NOT_EXIST == ret) {
need_check_group_by_ = false;
ret = OB_SUCCESS;
} else {
LOG_WARN("Failed to search in hashset", K(ret), K(col_offset));
}
}
}
}
}
return ret;
}
int ObVectorStore::alloc_group_by_cell(const ObTableAccessParam &param)
{
int ret = OB_SUCCESS;
@ -214,6 +260,9 @@ int ObVectorStore::alloc_group_by_cell(const ObTableAccessParam &param)
LOG_WARN("Failed to init group by cell", K(ret));
}
}
if (OB_SUCC(ret) && check_need_group_by(param)) {
LOG_WARN("Failed to check need group by", K(ret), K(param));
}
}
return ret;
}
@ -274,7 +323,7 @@ int ObVectorStore::fill_rows(
ret = OB_ERR_UNEXPECTED;
LOG_WARN("Unexpected vector store count", K(ret), K_(count), KP_(group_by_cell));
} else if (FALSE_IT(reader = scanner.get_reader())) {
} else if (OB_FAIL(check_can_group_by(reader, begin_index, end_index, res, can_group_by))) {
} else if (need_check_group_by_ && OB_FAIL(check_can_group_by(reader, begin_index, end_index, res, can_group_by))) {
LOG_WARN("Failed to checkout pushdown group by", K(ret));
} else if (can_group_by) {
if (OB_FAIL(fill_group_by_rows(group_idx, reader, begin_index, end_index, res))) {

View File

@ -95,6 +95,7 @@ protected:
common::hash::ObHashSet<int32_t> *agg_col_mask,
bool &is_agg_mask) const;
int alloc_group_by_cell(const ObTableAccessParam &param);
int check_need_group_by(const ObTableAccessParam &param);
int64_t count_;
// exprs needed fill in
@ -107,6 +108,7 @@ protected:
ObGroupByCellBase *group_by_cell_;
const ObTableIterParam *iter_param_;
sql::ObBitVector *skip_bit_;
bool need_check_group_by_;
};
}