Adrian Klaver <adrian.klaver@xxxxxxxxxxx> writes: > On 11/17/23 10:30 AM, Gabriel Sánchez wrote: >> I don't understand why the presence of a CTE that ends up not being >> included in the final query affects the result set. Could this be a >> bug, or is there something I don't understand? > I would say it has to do with what '...' is doing? We'd need to see a complete example to do more than speculate. The planner definitely does skip unreferenced SELECT CTEs, though. regards, tom lane