[CP] Fix the issue of incorrect results with batch NLJ + SET OP
This commit is contained in:
@ -1407,9 +1407,9 @@ int ObTableScanOp::do_init_before_get_row()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (need_init_before_get_row_) {
|
||||
LOG_DEBUG("do init before get row", K(MY_SPEC.use_dist_das_), K(MY_SPEC.gi_above_));
|
||||
LOG_DEBUG("do init before get row", K(MY_SPEC.id_), K(MY_SPEC.use_dist_das_), K(MY_SPEC.gi_above_));
|
||||
if (OB_UNLIKELY(iter_end_)) {
|
||||
//do nothing
|
||||
LOG_DEBUG("do init before get row meet iter end", K(MY_SPEC.id_));
|
||||
} else {
|
||||
if (MY_SPEC.gi_above_) {
|
||||
ObGranuleTaskInfo info;
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
#include "sql/optimizer/ob_log_exchange.h"
|
||||
#include "sql/optimizer/ob_log_table_scan.h"
|
||||
#include "sql/optimizer/ob_log_join_filter.h"
|
||||
#include "sql/optimizer/ob_log_set.h"
|
||||
#include "sql/optimizer/ob_optimizer_util.h"
|
||||
#include "sql/optimizer/ob_log_granule_iterator.h"
|
||||
#include "sql/rewrite/ob_transform_utils.h"
|
||||
@ -1414,6 +1415,13 @@ int ObLogJoin::check_if_disable_batch(ObLogicalOperator* root, bool &can_use_bat
|
||||
LOG_WARN("failed to check if disable batch", K(ret));
|
||||
}
|
||||
} else if (log_op_def::LOG_SET == root->get_type()) {
|
||||
ObLogSet *log_set = static_cast<ObLogSet *>(root);
|
||||
if (log_set->get_set_op() != ObSelectStmt::UNION) {
|
||||
//Disable batch nested loop join that contains set operations other than UNION
|
||||
//because other set operations may involve short-circuit operations.
|
||||
//Currently, batch NLJ does not support short-circuit execution.
|
||||
can_use_batch_nlj = false;
|
||||
}
|
||||
for (int64_t i = 0; OB_SUCC(ret) && can_use_batch_nlj && i < root->get_num_of_child(); ++i) {
|
||||
ObLogicalOperator *child = root->get_child(i);
|
||||
if (OB_ISNULL(child)) {
|
||||
@ -1424,10 +1432,16 @@ int ObLogJoin::check_if_disable_batch(ObLogicalOperator* root, bool &can_use_bat
|
||||
}
|
||||
}
|
||||
} else if (log_op_def::LOG_JOIN == root->get_type()) {
|
||||
ObLogJoin *join = NULL;
|
||||
if (OB_ISNULL(join = static_cast<ObLogJoin *>(root))) {
|
||||
ObLogJoin *join = static_cast<ObLogJoin *>(root);
|
||||
ObSQLSessionInfo *session_info = NULL;
|
||||
ObLogPlan *plan = NULL;
|
||||
if (OB_ISNULL(plan = get_plan())
|
||||
|| OB_ISNULL(session_info = plan->get_optimizer_context().get_session_info())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("invalid input", K(ret));
|
||||
LOG_WARN("unexpected null", K(ret), K(plan), K(session_info));
|
||||
} else if (!session_info->is_spf_mlj_group_rescan_enabled()) {
|
||||
//Group rescan optimization for nested joins at multiple levels is disabled by default.
|
||||
can_use_batch_nlj = false;
|
||||
} else if (!join->can_use_batch_nlj()) {
|
||||
can_use_batch_nlj = false;
|
||||
LOG_TRACE("child join not support batch_nlj", K(root->get_name()));
|
||||
|
||||
@ -535,17 +535,10 @@ int ObLogSubPlanFilter::check_and_set_das_group_rescan()
|
||||
|| OB_ISNULL(session_info = plan->get_optimizer_context().get_session_info())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected null", K(ret));
|
||||
} else if (!session_info->is_spf_mlj_group_rescan_enabled()) {
|
||||
enable_das_group_rescan_ = false;
|
||||
} else if (OB_FAIL(session_info->get_nlj_batching_enabled(enable_das_group_rescan_))) {
|
||||
LOG_WARN("failed to get enable batch variable", K(ret));
|
||||
} else {
|
||||
omt::ObTenantConfigGuard tenant_config(TENANT_CONF(session_info->get_effective_tenant_id()));
|
||||
if (tenant_config.is_valid()) {
|
||||
enable_das_group_rescan_ = tenant_config->_enable_spf_batch_rescan;
|
||||
LOG_TRACE("trace disable hash groupby in second stage for three-stage",
|
||||
K(enable_das_group_rescan_));
|
||||
} else {
|
||||
enable_das_group_rescan_ = false;
|
||||
}
|
||||
}
|
||||
// check use batch
|
||||
for (int64_t i = 1; OB_SUCC(ret) && enable_das_group_rescan_ && i < get_num_of_child(); i++) {
|
||||
|
||||
@ -563,6 +563,18 @@ int ObSQLSessionInfo::is_adj_index_cost_enabled(bool &enabled, int64_t &stats_co
|
||||
return ret;
|
||||
}
|
||||
|
||||
//to control subplan filter and multiple level join group rescan
|
||||
bool ObSQLSessionInfo::is_spf_mlj_group_rescan_enabled() const
|
||||
{
|
||||
bool bret = false;
|
||||
int64_t tenant_id = get_effective_tenant_id();
|
||||
omt::ObTenantConfigGuard tenant_config(TENANT_CONF(tenant_id));
|
||||
if (tenant_config.is_valid()) {
|
||||
bret = tenant_config->_enable_spf_batch_rescan;
|
||||
}
|
||||
return bret;
|
||||
}
|
||||
|
||||
void ObSQLSessionInfo::destroy(bool skip_sys_var)
|
||||
{
|
||||
if (is_inited_) {
|
||||
|
||||
@ -1192,6 +1192,7 @@ public:
|
||||
int is_enable_range_extraction_for_not_in(bool &enabled) const;
|
||||
bool is_var_assign_use_das_enabled() const;
|
||||
int is_adj_index_cost_enabled(bool &enabled, int64_t &stats_cost_percent) const;
|
||||
bool is_spf_mlj_group_rescan_enabled() const;
|
||||
|
||||
ObSessionDDLInfo &get_ddl_info() { return ddl_info_; }
|
||||
void set_ddl_info(const ObSessionDDLInfo &ddl_info) { ddl_info_ = ddl_info; }
|
||||
|
||||
Reference in New Issue
Block a user