Skip to content

Commit 629cd5d

Browse files
committed
ORCA: Support create plan in singlenode mode
1 parent 0613f2a commit 629cd5d

File tree

10 files changed

+28
-21
lines changed

10 files changed

+28
-21
lines changed

.asf.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ github:
9696
- pax-ic-isolation2-opt-off
9797
- pax-ic-isolation2-opt-on
9898
- ic-expandshrink
99-
- ic-singlenode
99+
- ic-singlenode-opt-off
100+
- ic-singlenode-opt-on
100101
- ic-resgroup-v2
101102
- ic-contrib
102103
- ic-gpcontrib

.github/workflows/build-cloudberry.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,22 @@ jobs:
269269
{"test":"ic-expandshrink",
270270
"make_configs":["src/test/isolation2:installcheck-expandshrink"]
271271
},
272-
{"test":"ic-singlenode",
272+
{"test":"ic-singlenode-opt-off",
273273
"make_configs":["src/test/isolation:installcheck-singlenode",
274274
"src/test/singlenode_regress:installcheck-singlenode",
275275
"src/test/singlenode_isolation2:installcheck-singlenode"],
276+
"pg_settings":{
277+
"optimizer":"off",
278+
},
279+
"num_primary_mirror_pairs":0
280+
},
281+
{"test":"ic-singlenode-opt-on",
282+
"make_configs":["src/test/isolation:installcheck-singlenode",
283+
"src/test/singlenode_regress:installcheck-singlenode",
284+
"src/test/singlenode_isolation2:installcheck-singlenode"],
285+
"pg_settings":{
286+
"optimizer":"on",
287+
},
276288
"num_primary_mirror_pairs":0
277289
},
278290
{"test":"ic-resgroup-v2",

src/backend/gpopt/config/CConfigParamMapping.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
extern "C" {
1717
#include "postgres.h"
18-
18+
#include "cdb/cdbvars.h"
1919
#include "utils/guc.h"
2020
}
2121

@@ -379,6 +379,10 @@ CConfigParamMapping::PackConfigParamInBitset(
379379
}
380380
}
381381

382+
if (IS_SINGLENODE()) {
383+
traceflag_bitset->ExchangeSet(EopttraceSingleNodeMode);
384+
}
385+
382386
if (!optimizer_enable_nljoin)
383387
{
384388
CBitSet *nl_join_bitset = CXform::PbsNLJoinXforms(mp);

src/backend/gpopt/translate/CTranslatorUtils.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ CTranslatorUtils::GetTableDescr(CMemoryPool *mp, CMDAccessor *md_accessor,
150150
}
151151
else if (IMDRelation::ErelstorageForeign != rel->RetrieveRelStorageType() &&
152152
!optimizer_enable_master_only_queries &&
153+
!GPOS_FTRACE(EopttraceSingleNodeMode) &&
153154
(IMDRelation::EreldistrMasterOnly == distribution_policy))
154155
{
155156
// fall back to the planner for queries on master-only table if they are disabled with Orca. This is due to

src/backend/gpopt/utils/COptTasks.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -953,10 +953,9 @@ COptTasks::OptimizeTask(void *ptr)
953953
query_to_dxl_translator->GetCTEs();
954954
GPOS_ASSERT(nullptr != query_output_dxlnode_array);
955955

956-
BOOL is_master_only =
957-
!optimizer_enable_motions ||
958-
(!optimizer_enable_motions_masteronly_queries &&
959-
!query_to_dxl_translator->HasDistributedTables());
956+
BOOL is_master_only = !GPOS_FTRACE(EopttraceDisableMotions) ||
957+
GPOS_FTRACE(EopttraceSingleNodeMode) ||
958+
!query_to_dxl_translator->HasDistributedTables();
960959
// See NoteDistributionPolicyOpclasses() in src/backend/gpopt/translate/CTranslatorQueryToDXL.cpp
961960
BOOL use_legacy_opfamilies =
962961
(query_to_dxl_translator->GetDistributionHashOpsKind() ==

src/backend/gporca/libnaucrates/include/naucrates/traceflags/traceflags.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ enum EOptTraceFlag
8383
// print debug info of CTE
8484
EopttraceDebugCTE = 101020,
8585

86+
// Is singlenode
87+
EopttraceSingleNodeMode = 101021,
88+
8689
///////////////////////////////////////////////////////
8790
////////////////// transformations flags //////////////
8891
///////////////////////////////////////////////////////

src/backend/optimizer/plan/planner.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ standard_planner(Query *parse, const char *query_string, int cursorOptions,
373373
* PARALLEL RETRIEVE CURSOR is not supported by ORCA yet.
374374
*/
375375
if (optimizer &&
376-
GP_ROLE_DISPATCH == Gp_role &&
376+
IS_QD_OR_SINGLENODE() &&
377377
IS_QUERY_DISPATCHER() &&
378378
(cursorOptions & CURSOR_OPT_SKIP_FOREIGN_PARTITIONS) == 0 &&
379379
(cursorOptions & CURSOR_OPT_PARALLEL_RETRIEVE) == 0)

src/backend/utils/misc/guc_gp.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,6 @@ char *optimizer_search_strategy_path = NULL;
322322
/* GUCs to tell Optimizer to enable a physical operator */
323323
bool optimizer_enable_nljoin;
324324
bool optimizer_enable_indexjoin;
325-
bool optimizer_enable_motions_masteronly_queries;
326325
bool optimizer_enable_motions;
327326
bool optimizer_enable_motion_broadcast;
328327
bool optimizer_enable_motion_gather;
@@ -2175,16 +2174,6 @@ struct config_bool ConfigureNamesBool_gp[] =
21752174
true,
21762175
NULL, NULL, NULL
21772176
},
2178-
{
2179-
{"optimizer_enable_motions_masteronly_queries", PGC_USERSET, DEVELOPER_OPTIONS,
2180-
gettext_noop("Enable plans with Motion operators in the optimizer for queries with no distributed tables."),
2181-
NULL,
2182-
GUC_NO_SHOW_ALL | GUC_NOT_IN_SAMPLE
2183-
},
2184-
&optimizer_enable_motions_masteronly_queries,
2185-
false,
2186-
NULL, NULL, NULL
2187-
},
21882177
{
21892178
{"optimizer_enable_motions", PGC_USERSET, DEVELOPER_OPTIONS,
21902179
gettext_noop("Enable plans with Motion operators in the optimizer."),

src/include/utils/guc.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,6 @@ extern char *optimizer_search_strategy_path;
501501
/* GUCs to tell Optimizer to enable a physical operator */
502502
extern bool optimizer_enable_nljoin;
503503
extern bool optimizer_enable_indexjoin;
504-
extern bool optimizer_enable_motions_masteronly_queries;
505504
extern bool optimizer_enable_motions;
506505
extern bool optimizer_enable_motion_broadcast;
507506
extern bool optimizer_enable_motion_gather;

src/include/utils/unsync_guc_name.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,6 @@
420420
"optimizer_enable_motion_gather",
421421
"optimizer_enable_motion_redistribute",
422422
"optimizer_enable_motions",
423-
"optimizer_enable_motions_masteronly_queries",
424423
"optimizer_enable_multiple_distinct_aggs",
425424
"optimizer_enable_nljoin",
426425
"optimizer_enable_outerjoin_rewrite",

0 commit comments

Comments
 (0)