Don't use Orca to plan trivial constant queries#400
Open
Alena0704 wants to merge 1 commit into
Open
Conversation
Alena0704
marked this pull request as draft
July 7, 2026 08:21
Alena0704
force-pushed
the
orca-skip-constant-select
branch
from
July 7, 2026 08:50
25c8169 to
8e4ab9e
Compare
andr-sokolov
reviewed
Jul 7, 2026
andr-sokolov
reviewed
Jul 7, 2026
Comment on lines
+5879
to
+5882
| return parse->commandType == CMD_SELECT && | ||
| parse->rtable == NIL && | ||
| !parse->hasSubLinks && | ||
| parse->parentStmtType == PARENTSTMTTYPE_NONE; |
Contributor
There was a problem hiding this comment.
I think we should somehow change this condition to don't affect this test
select aggfns(a,b,c)
from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c);
-INFO: GPORCA failed to produce a plan, falling back to planner
-DETAIL: Feature not supported: ROW EXPRESSION
-CONTEXT: SQL function "aggfns_trans" during startup
Contributor
Author
There was a problem hiding this comment.
I had to update the expected .out files because we now never invoke Orca for trivial constant queries, so there is nothing to fail and the notice is gone.
Alena0704
force-pushed
the
orca-skip-constant-select
branch
4 times, most recently
from
July 9, 2026 07:26
f0ece2e to
66d4c4a
Compare
Queries such as "SELECT 42" have no range table and nothing to distribute across segments. Sending them to Orca brings no benefit and only adds optimization overhead before falling back to the Postgres planner anyway.
Alena0704
force-pushed
the
orca-skip-constant-select
branch
2 times, most recently
from
July 9, 2026 11:11
90844bd to
6b7ed8f
Compare
Contributor
Author
|
Just in case, I'll write about changes in out files of regression tests. All changes stem from one cause: trivial constant SELECTs with no range table (SELECT 1, SELECT pg_column_size(...), SELECT pg_lock_status()) now bypass ORCA and are planned by the Postgres planner.
|
Alena0704
marked this pull request as ready for review
July 12, 2026 23:02
| Optimizer: Postgres query optimizer | ||
| (2 rows) | ||
|
|
||
| explain select pg_lock_status(); |
Contributor
There was a problem hiding this comment.
This query is not a trivial constant query, but Orca doesn't plan it now. Fix please the PR description
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Don't use Orca to plan trivial constant queries
Queries such as "SELECT 42" have no range table and nothing to distribute across segments. Sending them to Orca brings no benefit and only adds optimization overhead before falling back to the Postgres planner anyway.