Erwin Brandstetter <brsaweda@xxxxxxxxx> writes: >> The following operations are always parallel restricted. >> - Scans of common table expressions (CTEs). > Now I am unsure whether I can use `PARALLEL SAFE` for functions containing > a CTE (while fulfilling all other criteria)? AFAIR, the reason for treating CTEs as parallel restricted is simply to guarantee single evaluation of the CTE. Within a function, that would only matter per-function-execution, so I can't see why a function containing such a query couldn't be pushed down to workers for execution. regards, tom lane