Skip to content

Commit

Permalink
Enable ORCA if lib is loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
whitehawk committed Oct 30, 2024
1 parent b28d17a commit cd9637a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 8 additions & 0 deletions gpcontrib/gp_orca/gporca.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include "utils/memutils.h"
#include "utils/guc.h"

extern bool optimizer;

extern void InitGPOPT();
extern void TerminateGPOPT();

Expand Down Expand Up @@ -119,6 +121,9 @@ _PG_init(void)

prev_planner = planner_hook;
planner_hook = gp_orca_planner;

/* enable orca here */
optimizer = true;
}
}

Expand All @@ -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();
Expand Down
3 changes: 0 additions & 3 deletions src/backend/optimizer/plan/planner.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit cd9637a

Please sign in to comment.