Re: CTE Materialization

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Paul van der Linden <paul(dot)doskabouter(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: CTE Materialization
Date: 2021-12-02 22:34:32
Message-ID: CAKFQuwYCuq6SnpS8_KeGZOdVvy+XvsL-9z2k7iYy_PDX_hWsLw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thursday, December 2, 2021, Paul van der Linden <
paul(dot)doskabouter(at)gmail(dot)com> wrote:

> Hi,
>
> when switching to postgres 14 (from 11) I'm having some slow queries
> because of inlining of CTE's.
> I know I can get the same result as with PG11 when adding MATERIALIZED to
> the cte, but the same application also needs to be able to run on older
> postgres versions, so that is a no-go.
> Is there any other way that I can have materialized cte's in PG14 while
> still be compatible with older PG versions?
> Much appreciated,
>

The usual anti-inlining hack is to add an “offset 0” to the query. Haven’t
tried it in 14 myself though.

David J.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Paul van der Linden 2021-12-02 23:20:05 Re: CTE Materialization
Previous Message Adrian Klaver 2021-12-02 22:22:01 Re: Require details that how to find user creation date in postgresql Database