Re: SQL functions not being inlined - Mailing list pgsql-general

From Tom Lane
Subject Re: SQL functions not being inlined
Date
Msg-id 28134.1335930256@sss.pgh.pa.us
Whole thread Raw
In response to SQL functions not being inlined  (Evan Martin <postgresql@realityexists.net>)
Responses Re: SQL functions not being inlined
List pgsql-general
Evan Martin <postgresql@realityexists.net> writes:
> 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. ...
> This is quite slow, especially when I have a WHERE clause that narrows
> down the set of rows from 100,000 to 10 or so. I suspect it's evaluating
> the function first and filtering it afterwards and perhaps not using the
> index, either.

Well, rather than suspecting, you should use EXPLAIN to find out whether
the functions are inlined or not.  The particular example you give here
seems inlinable to me, but maybe some of your other cases aren't.

I concur with the other respondent that OVERLAPS is not the most
efficient way to deal with the sort of condition you have here, either.
Postgres basically doesn't know how to optimize OVERLAPS at all, whereas
the planner has heard of BETWEEN and other simple-comparison constructs.

            regards, tom lane

pgsql-general by date:

Previous
From: Chris Angelico
Date:
Subject: Re: SQL functions not being inlined
Next
From: Peter Eisentraut
Date:
Subject: Re: installation of plpython2.7