Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 346B79FB3FE for ; Sun, 18 Mar 2007 03:50:17 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-new, port 10024) with ESMTP id 88479-06 for ; Sun, 18 Mar 2007 03:50:10 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.172]) by postgresql.org (Postfix) with ESMTP id 895029FB362 for ; Sun, 18 Mar 2007 03:50:12 -0300 (ADT) Received: by ug-out-1314.google.com with SMTP id k3so933155ugf for ; Sat, 17 Mar 2007 23:50:11 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:to:subject:date:user-agent:mime-version:content-type:content-transfer-encoding:content-disposition:message-id:from; b=EqW7yXVF4iA2p17rTfHIBfVm9mYAu3z9LuDd3J7TUb/m0MfHazXT9min1ztpzWaOoGGh1346ZnaX8QVIdegj6pGDpcE/9bXSwTIUByEPzbamw7xSi6asx1wckbdXh7QD1L+my0MIhooGZvOF7cTZn5gnddF4jS99cptbwrpd1Fo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:to:subject:date:user-agent:mime-version:content-type:content-transfer-encoding:content-disposition:message-id:from; b=q4CzLfNVP44bS3CpvKXiViPKF/UjI3yhFQC5869XEZTurUwZ0CgCPbVXYANEv4gIkK0ilW7rEs2F8Yf25IZNWwVVyFd/Zb74O0s/4f4cPwXkX6/bb8054rbWd6CfRIbp5YoiQkcn7XWtkIiA9U5+7AIBdIIxmHSbhFSTLBhzyUI= Received: by 10.66.219.11 with SMTP id r11mr7578428ugg.1174200611288; Sat, 17 Mar 2007 23:50:11 -0700 (PDT) Received: from ?192.168.128.42? ( [62.94.42.33]) by mx.google.com with ESMTP id u1sm5764794uge.2007.03.17.23.50.10; Sat, 17 Mar 2007 23:50:10 -0700 (PDT) To: pgsql-performance@postgresql.org Subject: function call vs staright query Date: Sun, 18 Mar 2007 07:50:54 +0100 User-Agent: KMail/1.9.5 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200703180750.54703.Vincenzo.Romano@gmail.com> From: Vincenzo Romano X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200703/263 X-Sequence-Number: 23668 Hi all. I'm experiencing a strange behaviour with 8.1.8 (cannot do upgrades to 8.2 at the moment). On a 13+ million rows table I can do a query with results back in less than 100 ms. Result is a set of bigint. But when I encapsulate that query into an "SQL" function with three parameters the results come back in about one minute. The function contains just the same query as above. Of course there's been no change in indices or even into the table itself between the two tests. I'm almost sure I'm missing something, but have no clue about what! Any hint?