Skip site navigation (1) Skip section navigation (2)

Re: SQL function inlining (was: View vs function)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Tambet Matiisen" <t(dot)matiisen(at)aprote(dot)ee>
Cc: "Neil Conway" <neilc(at)samurai(dot)com>,pgsql-performance(at)postgresql(dot)org
Subject: Re: SQL function inlining (was: View vs function)
Date: 2005-03-23 16:55:28
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-performance
"Tambet Matiisen" <t(dot)matiisen(at)aprote(dot)ee> writes:
> I observed slowdowns when I declared SQL function as strict. There were
> no slowdowns, when I implmented the same function in plpgsql, in fact it
> got faster with strict, if parameters where NULL. Could it be
> side-effect of SQL function inlining? Is there CASE added around the
> function to not calculate it, when one of the parameters is NULL?

IIRC we will not inline a STRICT SQL function if the resulting
expression would not behave strict-ly.  This is clearly a necessary rule
because inlining would change the behavior otherwise.  But the test for
it is pretty simplistic: CASEs are considered not strict, period.  So I
think you are measuring the difference between inlined and not-inlined.

I'd suggest just leaving off the STRICT if you are writing a SQL
function you hope to have inlined.

			regards, tom lane

In response to


pgsql-performance by date

Next:From: Andrew SullivanDate: 2005-03-23 16:58:07
Subject: Re: PostgreSQL on Solaris 8 and ufs
Previous:From: Dave CramerDate: 2005-03-23 12:53:10
Subject: Re: Hardware questions

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group