Re: CTE Materialization

2021-12-10 Thread Richard Michael
On Thu, 9 Dec 2021 at 10:29, Paul van der Linden wrote: > This one quite nicely explains it: > https://stackoverflow.com/questions/14897816/how-can-i-prevent-postgres-from-inlining-a-subquery > Given indexes applicable to multiple expressions in a WHERE condition, how does postgres decide which

Re: CTE Materialization

2021-12-09 Thread Paul van der Linden
This one quite nicely explains it: https://stackoverflow.com/questions/14897816/how-can-i-prevent-postgres-from-inlining-a-subquery On Wed, Dec 8, 2021 at 3:14 AM David G. Johnston wrote: > On Tue, Dec 7, 2021 at 6:40 PM Дмитрий Иванов > wrote: > >> I beg your pardon. >> The problem is more or

Re: CTE Materialization

2021-12-08 Thread Дмитрий Иванов
Спасибо! -- С уважением, Дмитрий! ср, 8 дек. 2021 г. в 22:58, Paul van der Linden : > This one quite nicely explains it: > https://stackoverflow.com/questions/14897816/how-can-i-prevent-postgres-from-inlining-a-subquery > > On Wed, Dec 8, 2021 at 3:14 AM David G. Johnston < >

Re: CTE Materialization

2021-12-07 Thread David G. Johnston
On Tue, Dec 7, 2021 at 6:40 PM Дмитрий Иванов wrote: > 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. > > A subquery with a LIMIT clause cannot have where clause expressions in

Re: CTE Materialization

2021-12-07 Thread Дмитрий Иванов
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 : > It did indeed work as expected. > Took the query down from

Re: CTE Materialization

2021-12-06 Thread Paul van der Linden
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.johns...@gmail.com> wrote: > On Thursday, December 2, 2021, Paul van der Linden < > paul.doskabou...@gmail.com> wrote: > >> Hi,

Re: CTE Materialization

2021-12-06 Thread Paul van der Linden
Thanks a lot, completely forgot that one! Gonna test that tomorrow... On Thu, Dec 2, 2021 at 11:34 PM David G. Johnston < david.g.johns...@gmail.com> wrote: > On Thursday, December 2, 2021, Paul van der Linden < > paul.doskabou...@gmail.com> wrote: > >> Hi, >> >> when switching to postgres 14

Re: CTE Materialization

2021-12-02 Thread David G. Johnston
On Thursday, December 2, 2021, Paul van der Linden < paul.doskabou...@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

CTE Materialization

2021-12-02 Thread Paul van der Linden
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