On Wed, May 2, 2012 at 12:43 PM, Evan Martin <postgresql@xxxxxxxxxxxxxxxxx> wrote: > Some of my functions are running much slower than doing the same query > "inline" and I'd like to know if there's a way to fix that. > [chomp analysis and examples] Is there any possibility that you could recode your functions as views? The optimizer can push predicates down into views but not, it would appear, into functions. In the specific example given, I would be looking, not for an OVERLAPS, but a simple comparison: SELECT * FROM thing_timeslice WHERE '2012-05-01' BETWEEN valid_time_begin AND COALESCE(valid_time_end, 'infinity'::timestamp) That may make it easier for the optimizer. ChrisA -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general