Re: Can functions containing a CTE be PARALLEL SAFE?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Erwin Brandstetter <brsaweda(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Can functions containing a CTE be PARALLEL SAFE?
Date: 2019-10-17 09:20:03
Message-ID: 19531.1571304003@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Erwin Brandstetter <brsaweda(at)gmail(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Morris de Oryx 2019-10-17 09:33:41 Re: Has there been any discussion of custom dictionaries being defined in the database?
Previous Message Tom Lane 2019-10-17 08:33:58 Re: Has there been any discussion of custom dictionaries being defined in the database?