X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6F9F753554 for ; Wed, 23 Mar 2005 16:55:48 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 46118-07 for ; Wed, 23 Mar 2005 16:55:40 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 5DF1653558 for ; Wed, 23 Mar 2005 16:55:40 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2NGtSZB007636; Wed, 23 Mar 2005 11:55:28 -0500 (EST) To: "Tambet Matiisen" Cc: "Neil Conway" , pgsql-performance@postgresql.org Subject: Re: SQL function inlining (was: View vs function) In-reply-to: References: Comments: In-reply-to "Tambet Matiisen" message dated "Wed, 23 Mar 2005 12:03:26 +0200" Date: Wed, 23 Mar 2005 11:55:28 -0500 Message-ID: <7635.1111596928@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200503/491 X-Sequence-Number: 11196 "Tambet Matiisen" 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