A CTE is a named subquery that can make complex SQL easier to read. Performance gotcha: in some cases the planner may materialize the CTE (compute it fully) instead of inlining it, which can be slower. In newer Postgres versions CTEs are often inlined, but you can still force materialization.