From: Tom Lane <tgl@sss.pgh.pa.us>
To: Erwin Brandstetter <brsaweda@gmail.com>
Cc: pgsql-general@postgresql.org
Subject: Re: Can functions containing a CTE be PARALLEL SAFE?
Date: Thu, 17 Oct 2019 11:20:03 +0200
Message-ID: <19531.1571304003@sss.pgh.pa.us> (raw)
In-Reply-To: <CAGHENJ6jnwGBn5UG3ZjsTkOtvt1nRKuapcL9wx0Qx0H=HVvqxQ@mail.gmail.com>
References: <CAGHENJ6jnwGBn5UG3ZjsTkOtvt1nRKuapcL9wx0Qx0H=HVvqxQ@mail.gmail.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, brsaweda@gmail.com
Subject: Re: Can functions containing a CTE be PARALLEL SAFE?
In-Reply-To: <19531.1571304003@sss.pgh.pa.us>
References: <CAGHENJ6jnwGBn5UG3ZjsTkOtvt1nRKuapcL9wx0Qx0H=HVvqxQ@mail.gmail.com> <19531.1571304003@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox