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

From Chris Angelico
Subject Re: SQL functions not being inlined
Date
Msg-id CAPTjJmpowjy+Ghcq-Km3Xeer+fmW1F-Cwz3DObc2WHTg=bgH0g@mail.gmail.com
Whole thread Raw
In response to SQL functions not being inlined  (Evan Martin <postgresql@realityexists.net>)
List pgsql-general
On Wed, May 2, 2012 at 12:43 PM, Evan Martin
<postgresql@realityexists.net> 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

pgsql-general by date:

Previous
From: Evan Martin
Date:
Subject: SQL functions not being inlined
Next
From: Tom Lane
Date:
Subject: Re: SQL functions not being inlined