Re: PostgreSQL select-only CTE removal is too aggressive?

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Kirill Reshke <reshkekirill(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: PostgreSQL select-only CTE removal is too aggressive?
Date: 2026-06-29 23:42:21
Message-ID: CAKFQuwYH5+qz4x=ZacZkwdpJ6fOC+=OVppH6NugFVC0fBAus_A@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jun 29, 2026 at 12:58 PM Kirill Reshke <reshkekirill(at)gmail(dot)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.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2026-06-29 23:55:57 Re: Fix publisher-side sequence permission reporting
Previous Message Michael Paquier 2026-06-29 23:35:36 Re: [PATCH] Don't call ereport(ERROR) from recovery target GUC assign hooks