Re: CTE inlining

From: Adam Brusselback <adambrusselback(at)gmail(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Ilya Shkuratov <motr(dot)ilya(at)ya(dot)ru>, Vik Fearing <vik(dot)fearing(at)2ndquadrant(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, David Fetter <david(at)fetter(dot)org>, Claudio Freire <klaussfreire(at)gmail(dot)com>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>, Merlin Moncure <mmoncure(at)gmail(dot)com>, Andreas Karlsson <andreas(at)proxel(dot)se>, Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CTE inlining
Date: 2017-05-15 15:57:20
Message-ID: CAMjNa7dvpNKmXCmKzsvBCuw03muyE2FCTZqtj2qZBE3ynrk96w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

From a user's perspective:

>I think most people prefer #2 because:

>
>* most users writing queries prefer #2

> >* most users assume full optimization and it seems natural to turn

> > _off_ an optimization via a keyword

> >* while some queries can be inlined, all queries can be materialized,

> > so doing #1 means INLINE would be only a preference, which could be

> > confusing

I completely agree with this reasoning. I have a few queries I would have
to touch to add "MATERIALIZED", but the vast majority of CTE's in my
codebase would get a speedup. It would allow usage of CTE's more freely
than now. I currently avoid them unless it really simplifies a query
because of the optimization fence.

Not that my opinion holds any weight, but the extra keyword for enabling
the optimization fence is my preference. By default trying to optimize
more is a good thing IMO.

>
>Anyway, I am very glad we are considering addressing this in PG 11.

Seconded, this is a sore spot for me when using Postgres, and i'd love to
not have it be an issue any more.

Thanks,
-Adam

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Mark Dilger 2017-05-15 16:18:18 Re: Event triggers + table partitioning cause server crash in current master
Previous Message Peter Eisentraut 2017-05-15 15:53:49 Re: postgres 9.6.2 update breakage