Re: STRICT SQL functions never inline

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-performance(at)postgresql(dot)org
Cc: Josh Berkus <josh(at)agliodbs(dot)com>
Subject: Re: STRICT SQL functions never inline
Date: 2011-11-09 00:25:36
Message-ID: 2035036.0LnEqdmoaV@alap2
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Tuesday, November 08, 2011 15:29:03 Josh Berkus wrote:
> Folks,
>
> After having some production issues, I did some testing and it seems
> that any SQL function declared STRICT will never inline. As a result,
> it won't work with either indexes (on the underlying predicate) or
> partitioning.
>
> This seems like a horrible gotcha for our users. At the very least I'd
> like to document it (in CREATE FUNCTION, presumably), but it would be
> better to fix it. Thoughts?
I am all for documenting it somewhere. There were lots of people hit by it in
the past - e.g. the postgis folks.
Its not so easy to fix though. The problem is that straight inlining would
change the behaviour because suddenly the expression might not return NULL
anymore even though one of the parameters is NULL. Or even cause more problems
because the content wasn't prepared to handle NULLs.
It would be possible to inline a CASE $1 IS NULL OR $2 IS NULL .... THEN NULL
ELSE orig_expression END but that would be usefull in far fewer cases because
it won't help much in most cases and actually might hurt performance in some.

Andres

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Tom Lane 2011-11-09 00:29:34 Re: STRICT SQL functions never inline
Previous Message Josh Berkus 2011-11-08 23:29:03 STRICT SQL functions never inline