Skip to content

Commit 5dc8186

Browse files
author
kongfanshen
committed
ORCA: add optimizer_enable_right_semi_join GUC
Adds a GUC (default on) to enable/disable GPORCA's right semi/anti hash join xforms (CXformLeftSemiJoin2RightSemiHashJoin / CXformLeftAntiSemiJoin2RightAntiSemiHashJoin). When turned off, the xforms are disabled via the standard CConfigParamMapping traceflag mechanism (GPOPT_DISABLE_XFORM_TF), so ORCA falls back to its regular left-semi / anti plans. Serves both as a kill-switch for the new plan shape and as the on/off toggle for before/after performance comparisons (e.g. TPC-H Q21). The GUC is registered in unsync_guc_name.h (per-segment, no QD/QE sync required), matching the other optimizer_enable_* developer GUCs. SET optimizer_enable_right_semi_join = off; -- ORCA uses plain Hash Semi Join SET optimizer_enable_right_semi_join = on; -- ORCA may use Hash Right Semi Join
1 parent db20797 commit 5dc8186

4 files changed

Lines changed: 23 additions & 0 deletions

File tree

src/backend/gpopt/config/CConfigParamMapping.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,15 @@ CConfigParamMapping::PackConfigParamInBitset(
442442
hash_join_bitste->Release();
443443
}
444444

445+
// disable right semi/anti hash join (Mark Join) xforms if the GUC is off
446+
if (!optimizer_enable_right_semi_join)
447+
{
448+
traceflag_bitset->ExchangeSet(
449+
GPOPT_DISABLE_XFORM_TF(CXform::ExfLeftSemiJoin2RightSemiHashJoin));
450+
traceflag_bitset->ExchangeSet(GPOPT_DISABLE_XFORM_TF(
451+
CXform::ExfLeftAntiSemiJoin2RightAntiSemiHashJoin));
452+
}
453+
445454
if (!optimizer_enable_dynamictablescan)
446455
{
447456
// disable dynamic table scan if the corresponding GUC is turned off

src/backend/utils/misc/guc_gp.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ bool optimizer_enable_dml;
352352
bool optimizer_enable_dml_constraints;
353353
bool optimizer_enable_master_only_queries;
354354
bool optimizer_enable_hashjoin;
355+
bool optimizer_enable_right_semi_join = true;
355356
bool optimizer_enable_dynamictablescan;
356357
bool optimizer_enable_dynamicindexscan;
357358
bool optimizer_enable_dynamicindexonlyscan;
@@ -2354,6 +2355,17 @@ struct config_bool ConfigureNamesBool_gp[] =
23542355
NULL, NULL, NULL
23552356
},
23562357

2358+
{
2359+
{"optimizer_enable_right_semi_join", PGC_USERSET, DEVELOPER_OPTIONS,
2360+
gettext_noop("Enables the optimizer's use of right semi/anti hash join plans."),
2361+
NULL,
2362+
GUC_NO_SHOW_ALL | GUC_NOT_IN_SAMPLE
2363+
},
2364+
&optimizer_enable_right_semi_join,
2365+
true,
2366+
NULL, NULL, NULL
2367+
},
2368+
23572369
{
23582370
{"optimizer_enable_dynamictablescan", PGC_USERSET, DEVELOPER_OPTIONS,
23592371
gettext_noop("Enables the optimizer's use of plans with dynamic table scan."),

src/include/utils/guc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,7 @@ extern bool optimizer_enable_dml_constraints;
540540
extern bool optimizer_enable_direct_dispatch;
541541
extern bool optimizer_enable_master_only_queries;
542542
extern bool optimizer_enable_hashjoin;
543+
extern bool optimizer_enable_right_semi_join;
543544
extern bool optimizer_enable_dynamictablescan;
544545
extern bool optimizer_enable_dynamicindexscan;
545546
extern bool optimizer_enable_dynamicindexonlyscan;

src/include/utils/unsync_guc_name.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@
424424
"optimizer_discard_redistribute_hashjoin",
425425
"optimizer_enable_indexjoin",
426426
"optimizer_enable_indexonlyscan",
427+
"optimizer_enable_right_semi_join",
427428
"optimizer_enable_indexscan",
428429
"optimizer_enable_master_only_queries",
429430
"optimizer_enable_materialize",

0 commit comments

Comments
 (0)