Skip to content

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

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

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

Conversation

@Alena0704
Copy link
Copy Markdown
Contributor

orca: fallback to Postgres optimizer on cross-slice replicated CTE Consumer (#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

…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-29 branch from 400f934 to 6e31183 Compare May 6, 2026 07:56
@leborchuk leborchuk merged commit 5ad8245 into OPENGPDB_6_29_STABLE May 7, 2026
19 of 20 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