Richard Huxton <dev@xxxxxxxxxxxx> writes: > I must say I thought recent versions of PG delayed planning the query > until first call though. No, you're thinking of parameterized queries sent through the FE/BE protocol. Functions still plan without any assumptions about parameter values. regards, tom lane