-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move optimizer_enable_query_parameter GUC to Orca extension #1172
base: feature/ADBDEV-6552
Are you sure you want to change the base?
Conversation
Can we revert 38f4cb8 instead of replacing GUC with hook? The purpose is to make it simpler bumping PostgreSQL version, to reduce difference between PostgreSQL and GPDB, but the diff in choose_custom_plan() is increased. |
PlanCacheMode mode = choose_custom_plan_hook(plansource, boundParams, intoClause); | ||
|
||
if (mode == PLAN_CACHE_MODE_FORCE_GENERIC_PLAN) | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was such a return possible before the patch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Speaking about Orca - orca_choose_custom_plan()
doesn't return PLAN_CACHE_MODE_FORCE_GENERIC_PLAN
. Speaking about choose_custom_plan()
in general - similar logic is already implenented for plan_cache_mode
GUC, which can force the decision.
Overall, the delta should preserve previous logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar logic is already implenented for
plan_cache_mode
GUC, which can force the decision.
Can we use it instead of the new hook?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about it, but that means we'll need to change plan_cache_mode
each time optimizer
and optimizer_enable_query_parameter
are changed. Such non-obvious coupling between GUCs doesn't seem a proper thing. And what if user also sets the optimizer_enable_query_parameter
GUC? And we'll need somehow to handle cases when user sets the GUC after Orca has done it, and vice versa.
This approach seems too error prone, so I decided not go this route.
return PLAN_CACHE_MODE_FORCE_CUSTOM_PLAN; | ||
|
||
if (prev_choose_custom_plan_hook) | ||
return prev_choose_custom_plan_hook(plansource, boundParams, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can multiple extensions set their own hooks in choose_custom_plan_hook
that return different results? And what to do about it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In theory it is possible, but I think that only planner extension would be interested in using choose_custom_plan_hook
, and we do not support more than one external planner at the same time currently. So I guess currently it doesn't sound like a real problem.
If I revert the logic of the mentioned commit, I start to get failure in the test: diff -I HINT: -I CONTEXT: -I GP_IGNORE: -U3 /usr/re/share/ws98-ADBDEV-6630/gpdb/src/test/regress/expected/window_optimizer.out /usr/re/share/ws98-ADBDEV-6630/gpdb/src/test/regress/results/window.out
--- /usr/re/share/ws98-ADBDEV-6630/gpdb/src/test/regress/expected/window_optimizer.out 2025-01-14 16:31:46.185514939 +1000
+++ /usr/re/share/ws98-ADBDEV-6630/gpdb/src/test/regress/results/window.out 2025-01-14 16:31:46.311578075 +1000
@@ -1334,8 +1338,6 @@
SELECT i, min(i) over (order by i range between '1 day' preceding and '10 days' following) as min_i
FROM generate_series(now(), now()+'100 days'::interval, '1 hour') i;
SELECT pg_get_viewdef('v_window');
-INFO: GPORCA failed to produce a plan, falling back to Postgres-based planner
-DETAIL: Falling back to Postgres-based planner because GPORCA does not support the following feature: Non-default collation
pg_get_viewdef
------------
min(i.i) OVER (ORDER BY i.i RANGE BETWEEN '@ 1 day'::interval PRECEDING AND '@ 10 days'::interval FOLLOWING) AS min_i+
The query planning stops to fallback to Postgres planner. It looks that it's what the commit is talking about:
I don't think we should revert changes intended to fix test flakiness. |
Move optimizer_enable_query_parameter GUC to Orca extension
Problem:
'optimizer_enable_query_parameter' GUC is a setting that affects Orca behavior,
so we would like it to reside in Orca. But this GUC was also referenced by the
core (in 'choose_custom_plan()'). It prevented moving of the GUC to the
extension.
Fix:
In 'choose_custom_plan()' the GUC was used to make a decision whether to use
custom or generic plan in plan cache manager. In general, this decision can be
affected by different parameters, and a generic external planner should be able
to have control over this decision. Thus, this patch:
to the extension side.
extension previously.