Skip to content

orca: fallback to Postgres optimizer on cross-slice replicated CTE Co…#381

Merged
leborchuk merged 1 commit intoOPENGPDB_6_28_STABLEfrom
bugfix-cross-slice-shared-scan-cte-backport-28
May 7, 2026
Merged

orca: fallback to Postgres optimizer on cross-slice replicated CTE Co…#381
leborchuk merged 1 commit intoOPENGPDB_6_28_STABLEfrom
bugfix-cross-slice-shared-scan-cte-backport-28

Conversation

@Alena0704
Copy link
Copy Markdown
Contributor

orca: fallback to Postgres optimizer on cross-slice replicated CTE Consumer

Inspired by greengage 51fe92e: before Expr->DXL translation,
walk the physical tree and track which slice each CTE Producer
and Consumer lives on. If a Consumer is on a different slice
than its Producer and the Producer's distribution is replicated,
force a fallback to the Postgres optimizer.

The replicated filter is essential: ordinary cross-slice CTE plans
(non-replicated Producer with Gather/Redistribute Consumer) are a
normal ORCA pattern and must not trigger fallback.

51fe92e doesn't trigger when a CTE over a replicated table is
referenced from a scalar subquery, so the query hangs. This commit
replaces the single-point check with a whole-tree walker that
catches both cases.

Tests: bring the original qp_orca_fallback case from 51fe92e and add
a scalar-subquery reproducer in shared_scan guarded by
statement_timeout.

cherry-pick from 3a9aebf

…nsumer (#375)

Inspired by greengage 51fe92e: before Expr->DXL translation,
walk the physical tree and track which slice each CTE Producer
and Consumer lives on. If a Consumer is on a different slice
than its Producer and the Producer's distribution is replicated,
force a fallback to the Postgres optimizer.

The replicated filter is essential: ordinary cross-slice CTE plans
(non-replicated Producer with Gather/Redistribute Consumer) are a
normal ORCA pattern and must not trigger fallback.

51fe92e doesn't trigger when a CTE over a replicated table is
referenced from a scalar subquery, so the query hangs. This commit
replaces the single-point check with a whole-tree walker that
catches both cases.

Tests: bring the original qp_orca_fallback case from 51fe92e and add
a scalar-subquery reproducer in shared_scan guarded by
statement_timeout.

cherry-pick from 3a9aebf
@Alena0704 Alena0704 force-pushed the bugfix-cross-slice-shared-scan-cte-backport-28 branch from b0551df to 227e4c8 Compare May 6, 2026 07:56
@leborchuk leborchuk merged commit 92bdf77 into OPENGPDB_6_28_STABLE May 7, 2026
14 of 15 checks passed
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