Reputation: 3214
From the PostgreSQL manual:
The following operations are always parallel restricted:
Scans of common table expressions (CTEs).
Scans of temporary tables.
Why are parallel scans of CTEs and temporary tables restricted?
Upvotes: 1
Views: 479
Reputation: 44305
Note that CTE scans are only a barrier if they still exist after planning. If the CTE syntax was "inlined" during planning, it is not a barrier to parallel. I wonder if the docs should be changed to clarify that?
Upvotes: 3
Reputation: 211
Parallel restricted
Scans on CTE & Temp tables:
The reason is that both CTEs and temporary tables are private to the backend process that created them, and parallel worker processes are different processes that do not have access to the private resources of the leader process.
To make CTE scans parallel safe, CTEs would have to be materialized in shared memory.
https://stackoverflow.com/a/58445299/11094058
Upvotes: 3