X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 919BC11F7B64 for ; Tue, 11 Apr 2006 10:50:07 -0300 (ADT) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Score: 0.12 X-Spam-Level: X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id FPOJZSQ2v3xe for ; Tue, 11 Apr 2006 10:49:45 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.229]) by postgresql.org (Postfix) with ESMTP id 8FA0911F6C2F for ; Tue, 11 Apr 2006 10:49:48 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id i7so1673084wra for ; Tue, 11 Apr 2006 06:49:49 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=drF1QCSqAub//rSX59UtlXw9ZouN6BpVhcfOyDOEn5Z587Jhqr3QJYOGSQNiGWstfWhyFZ8JbiE3bXUgsWq0M9fspf2K7vMBwleIVvSULOPbnR8YbQHdEVqeILofdzKSafC1GvjhUeFGlk7wIGaBngqGWPKl5seyf8c/PBUR5Gc= Received: by 10.65.52.3 with SMTP id e3mr5040474qbk; Tue, 11 Apr 2006 06:49:48 -0700 (PDT) Received: by 10.65.137.8 with HTTP; Tue, 11 Apr 2006 06:49:48 -0700 (PDT) Message-ID: Date: Tue, 11 Apr 2006 09:49:48 -0400 From: "Merlin Moncure" To: "Simon Dale" Subject: Re: Stored Procedure Performance Cc: pgsql-performance@postgresql.org In-Reply-To: <416F947BF5BA9E40B5F9AA649422212E074DE930@ex-mail2.internal.rmplc.net> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <416F947BF5BA9E40B5F9AA649422212E074DE930@ex-mail2.internal.rmplc.net> X-Archive-Number: 200604/234 X-Sequence-Number: 18318 On 4/11/06, Simon Dale wrote: > I'm trying to evaluate PostgreSQL as a database that will have to store a > high volume of data and access that data frequently. One of the features = on > our wish list is to be able to use stored procedures to access the data a= nd > I was wondering if it is usual for stored procedures to perform slower on > PostgreSQL than raw SQL? pl/pgsql procedures are a very thin layer over the query engine.=20 Generally, they run about the same speed as SQL but you are not making apples to apples comparison. One of the few but annoying limitations of pl/pgsql procedures is that you can't return a select directly from the query engine but have to go through the return/return next paradigm which will be slower than raw query for obvious reasons. You can however return a refcursor and you may want to look at them in situations where you want to return arbitrary sets outside the query engine or between pl/pgsql functions. An example of using refcurors in that way is on my blog at http://people.planetpostgresql.org/merlin/index.php?/archives/2-Dealing-Wit= h-Recursive-Sets-With-PLPGSQL.html Generally, in my opinion if you want to really unlock the power of postgresql you have to master pl/pgsql. Go for it...it will work and work well. merlin merlin