4 ms·
Aren't CTEs still optimization barriers in Postgres, so wouldn't that make any subquert optimization problem worse?
by dragonwriter 5y ago
Aren't CTEs still optimization barriers in Postgres, so wouldn't that make any subquert optimization problem worse?
- CBLT 5y agoWasn't this solved in Postgres 12?[0] [0] https://www.depesz.com/2019/02/19/waiting-for-postgresql-12-allow-user-control-of-cte-materialization-and-change-the-default-behavior/ https://www.depesz.com/2019/02/19/waiting-for-postgresql-12-...
- kristjansson 5y agoMostly no, since PostgreSQL 12
- deleted 5y ago[deleted]
- srcreigh 5y agoDepends if materialization helps. As a silly example, if the CTE materializes 1/100th of a table via table scan, scanning 1/100th of a table N times may be faster than scanning the entire table N times.
- briffle 5y agoThe fun thing is, they have corrected a bunch of that in newer versions of postgresql. I'm surprised that the problem stemmed from an index where the 'AND NOT NULL' took forevery to scan, and they didn't include a partial index, or an index in a different order since they are sorted.
- yxhuvud 5y agoThat could even be a feature if used to compute just the list of active jobs. Later pgs might need to be explicit to reinsert the optimization barrier, as the implicit one for all Cates was removed.