"Shaun Thomas" <sthomas@xxxxxxxxxxxxxxxxxx> writes: > I can see the planner not liking the results of a function, > but a variable? That's a static value! Read what you wrote, and rethink... If you're desperate you can construct a query string with the variable value embedded as a literal, and then EXECUTE that. This isn't a great solution since it forces a re-plan on every execution. We've occasionally debated ways to do it better, but no such improvement will ever appear in 7.4 ;-) regards, tom lane