↑↓ select ↵ open ⌫ change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

Feature: Inlined WITH Queries (Common Table Expressions)

A WITH query that is neither recursive nor has any side-effects (e.g. an INSERT/UPDATE/DELETE) can be executed inline, which can lead to performance improvements. This behavior can be forced on a query by using the "NOT MATERIALIZED" clause, e.g.

WITH cte AS NOT MATERIALIZED ( SELECT * FROM a ) SELECT * FROM cte JOIN b ON b.id = cte.id;

For more information, please visit https://www.postgresql.org/docs/12/queries-with.html