Ryan pfp
Ryan

@ryansmith

A CTE (WITH) can be MATERIALIZED or NOT MATERIALIZED. When MATERIALIZED, the query is computed only once for the outer query. Good for reducing work. Not good when you reference the CTE multiple times with different predicates. NOT MATERIALIZED forces PG to "inline" the CTE which allows predicate push down but possibly duplicates work. The default is MATERIALIZED when a CTE is referenced more than once. https://www.postgresql.org/docs/current/queries-with.html#QUERIES-WITH-CTE-MATERIALIZATION
0 reply
0 recast
4 reactions