Re: SQL functions not being inlined

From: Chris Angelico <rosuav(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: SQL functions not being inlined
Date: 2012-05-02 03:23:14
Message-ID: CAPTjJmpowjy+Ghcq-Km3Xeer+fmW1F-Cwz3DObc2WHTg=bgH0g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, May 2, 2012 at 12:43 PM, Evan Martin
<postgresql(at)realityexists(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2012-05-02 03:44:16 Re: SQL functions not being inlined
Previous Message Evan Martin 2012-05-02 02:43:19 SQL functions not being inlined