From cd9637a2ed3dcbcbbdc861cd24add2f22f7e77e0 Mon Sep 17 00:00:00 2001 From: Roman Eskin Date: Wed, 30 Oct 2024 10:59:04 +1000 Subject: [PATCH] Enable ORCA if lib is loaded --- gpcontrib/gp_orca/gporca.c | 8 ++++++++ src/backend/optimizer/plan/planner.c | 3 --- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/gpcontrib/gp_orca/gporca.c b/gpcontrib/gp_orca/gporca.c index 7f4eecd0afa4..909f0dbe650f 100644 --- a/gpcontrib/gp_orca/gporca.c +++ b/gpcontrib/gp_orca/gporca.c @@ -10,6 +10,8 @@ #include "utils/memutils.h" #include "utils/guc.h" +extern bool optimizer; + extern void InitGPOPT(); extern void TerminateGPOPT(); @@ -119,6 +121,9 @@ _PG_init(void) prev_planner = planner_hook; planner_hook = gp_orca_planner; + + /* enable orca here */ + optimizer = true; } } @@ -128,6 +133,9 @@ _PG_fini(void) elog(LOG, "[GP_ORCA] _PG_fini"); if (Gp_role == GP_ROLE_DISPATCH) { + /* disable orca here */ + optimizer = false; + planner_hook = prev_planner; TerminateGPOPT(); diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c index bc96f034b232..621ddb0d502f 100644 --- a/src/backend/optimizer/plan/planner.c +++ b/src/backend/optimizer/plan/planner.c @@ -354,9 +354,6 @@ standard_planner(Query *parse, int cursorOptions, ParamListInfo boundParams) instr_time starttime; instr_time endtime; - if (optimizer) - elog(ERROR, "Add gp_orca to shared_preload_libraries"); - /* * Fall back to using the PostgreSQL planner in case Orca didn't run (in * utility mode or on a segment) or if it didn't produce a plan.