Received: from localhost (unknown [200.46.204.184]) by developer.postgresql.org (Postfix) with ESMTP id 09A492E005A for ; Wed, 16 Apr 2008 12:06:41 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 60268-03 for ; Wed, 16 Apr 2008 12:06:35 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.249]) by developer.postgresql.org (Postfix) with ESMTP id CF4172E004E for ; Wed, 16 Apr 2008 12:06:35 -0300 (ADT) Received: by an-out-0708.google.com with SMTP id c36so705459ana.33 for ; Wed, 16 Apr 2008 08:06:35 -0700 (PDT) Received: by 10.100.232.13 with SMTP id e13mr136227anh.89.1208358395093; Wed, 16 Apr 2008 08:06:35 -0700 (PDT) Received: by 10.100.151.11 with HTTP; Wed, 16 Apr 2008 08:06:35 -0700 (PDT) Message-ID: Date: Wed, 16 Apr 2008 11:06:35 -0400 From: "Gavin M. Roy" To: pgsql-performance@postgresql.org Subject: SQL Function Slowness, 8.3.0 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_4061_17570540.1208358395079" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200804/200 X-Sequence-Number: 29693 ------=_Part_4061_17570540.1208358395079 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline In 8.3.0, I'm seeing some oddities with SQL functions which I thought were immune to the planner data restrictions of plpgsql functions and the sort. Basically I have a query which executes in 5ms but when wrapped in a SQL function, takes 500ms. I've checked all the types passed in to make sure they match so there is no type conversions taking place in execution. I'm curious about the validity of my expectation that functions created with SQL as the language should be as fast as the straight SQL counterpart. I've previously not run into such an order of magnitude difference in using SQL functions. Is this a change of behavior in 8.3 from 8.2? Without specific examples, are there any recommendations on how to speed up these functions? Thanks, Gavin ------=_Part_4061_17570540.1208358395079 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline In 8.3.0, I'm seeing some oddities with SQL functions which I thought were immune to the planner data restrictions of plpgsql functions and the sort.  Basically I have a query which executes in 5ms but when wrapped in a SQL function, takes 500ms.  I've checked all the types passed in to make sure they match so there is no type conversions taking place in execution.

I'm curious about the validity of my expectation that functions created with SQL as the language should be as fast as the straight SQL counterpart.  I've previously not run into such an order of magnitude difference in using SQL functions.  Is this a change of behavior in 8.3 from 8.2?  Without specific examples, are there any recommendations on how to speed up these functions?

Thanks,

Gavin

------=_Part_4061_17570540.1208358395079--