Re: CTE Materialization - Mailing list pgsql-general

From Дмитрий Иванов
Subject Re: CTE Materialization
Date
Msg-id CAPL5KHrnziJECNq62DCnULjRS+EWmeG9qc3jxEQgPZixnLG8aA@mail.gmail.com
Whole thread Raw
In response to Re: CTE Materialization  (Paul van der Linden <paul.doskabouter@gmail.com>)
Responses Re: CTE Materialization  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-general
I beg your pardon.
The problem is more or less clear to me, but the solution is not. What does the "hack is to add an "offset 0" to the query" suggest? Thank you.
--
Regards, Dmitry!


вт, 7 дек. 2021 г. в 10:20, Paul van der Linden <paul.doskabouter@gmail.com>:
It did indeed work as expected.
Took the query down from over 18 hours to 20 minutes, so a huge win!

Paul

On Thu, Dec 2, 2021 at 11:34 PM David G. Johnston <david.g.johnston@gmail.com> wrote:
On Thursday, December 2, 2021, Paul van der Linden <paul.doskabouter@gmail.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.
 

pgsql-general by date:

Previous
From: Oskar Stenberg
Date:
Subject: Working with fixed-point calculations in C
Next
From: "David G. Johnston"
Date:
Subject: Re: CTE Materialization