Re: PostgreSQL select-only CTE removal is too aggressive? - Mailing list pgsql-hackers

From David G. Johnston
Subject Re: PostgreSQL select-only CTE removal is too aggressive?
Date
Msg-id CAKFQuwYH5+qz4x=ZacZkwdpJ6fOC+=OVppH6NugFVC0fBAus_A@mail.gmail.com
Whole thread
In response to Re: PostgreSQL select-only CTE removal is too aggressive?  (Kirill Reshke <reshkekirill@gmail.com>)
List pgsql-hackers
On Mon, Jun 29, 2026 at 12:58 PM Kirill Reshke <reshkekirill@gmail.com> wrote:
I have been thinking for a while about this optimization. The thing is, there is currently no way of forcing this CTE evaluation other than referencing it from other query parts. I think this is little clumsy. What if we use MATERIALIZE here for this purpose? So, 


I find myself usually, if something has side-effects, returning result information about what effects it had.  That means propagating the result (usually a jsonb object) out of the main query so the caller (usually a function) can grab ahold of it to return to the client.  Even just a row count and a label works.

David J.

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: [PATCH] Don't call ereport(ERROR) from recovery target GUC assign hooks
Next
From: Fujii Masao
Date:
Subject: Re: Fix publisher-side sequence permission reporting