Skip to content

Don't use Orca to plan trivial constant queries#400

Draft
Alena0704 wants to merge 1 commit into
OPENGPDB_STABLEfrom
orca-skip-constant-select
Draft

Don't use Orca to plan trivial constant queries#400
Alena0704 wants to merge 1 commit into
OPENGPDB_STABLEfrom
orca-skip-constant-select

Conversation

@Alena0704

Copy link
Copy Markdown
Contributor

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.

@Alena0704 Alena0704 marked this pull request as draft July 7, 2026 08:21
@Alena0704 Alena0704 force-pushed the orca-skip-constant-select branch from 25c8169 to 8e4ab9e Compare July 7, 2026 08:50
Comment thread src/backend/optimizer/plan/planner.c
Comment thread src/backend/optimizer/plan/planner.c Outdated
Comment thread src/backend/optimizer/plan/planner.c Outdated
Comment on lines +5879 to +5882
return parse->commandType == CMD_SELECT &&
parse->rtable == NIL &&
!parse->hasSubLinks &&
parse->parentStmtType == PARENTSTMTTYPE_NONE;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Alena0704 force-pushed the orca-skip-constant-select branch 4 times, most recently from f0ece2e to 66d4c4a Compare July 9, 2026 07:26
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 Alena0704 force-pushed the orca-skip-constant-select branch 2 times, most recently from 90844bd to 6b7ed8f Compare July 9, 2026 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants