pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Tambet Matiisen <t.matiisen@aprote.ee>
Cc: Neil Conway <neilc@samurai.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: SQL function inlining (was: View vs function)
Date: Wed, 23 Mar 2005 11:55:28 -0500
Message-ID: <7635.1111596928@sss.pgh.pa.us> (raw)
In-Reply-To: <A66A11DBF5525341AEF6B8DE39CDE770088060@black.aprote.com>
References: <A66A11DBF5525341AEF6B8DE39CDE770088060@black.aprote.com>

"Tambet Matiisen" <t.matiisen@aprote.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



view thread (2+ messages)

Message-ID: <7635.1111596928@sss.pgh.pa.us>
Permalink:  ../7635.1111596928@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/7635.1111596928@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, t.matiisen@aprote.ee, neilc@samurai.com
  Subject: Re: SQL function inlining (was: View vs function)
  In-Reply-To: <7635.1111596928@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox