Re: Can functions containing a CTE be PARALLEL SAFE? - Mailing list pgsql-general

From Erwin Brandstetter
Subject Re: Can functions containing a CTE be PARALLEL SAFE?
Date
Msg-id CAGHENJ6dF12ewNS=brvGfafi8tPu6WQ2usati7Occqni-htSnw@mail.gmail.com
Whole thread Raw
In response to Re: Can functions containing a CTE be PARALLEL SAFE?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Makes sense, thanks for the confirmation.
Maybe clarify in the manual?

Regards
Erwin

On Thu, Oct 17, 2019 at 11:20 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Erwin Brandstetter <brsaweda@gmail.com> 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

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: PostgreSQL memory usage
Next
From: Lizeth Solis Aramayo
Date:
Subject: RE: CVE-2018-1058