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 41B4211F712D for ; Tue, 11 Apr 2006 07:04:34 -0300 (ADT) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Score: 0.126 X-Spam-Level: X-Spam-Status: No, score=0.126 required=5 tests=[AWL=0.126] Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id SCENuKMVNI7W for ; Tue, 11 Apr 2006 07:04:25 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from pih-relay04.plus.net (pih-relay04.plus.net [212.159.14.131]) by postgresql.org (Postfix) with ESMTP id E430111F70FB for ; Tue, 11 Apr 2006 07:04:27 -0300 (ADT) Received: from [213.162.97.75] (helo=mail.metronet.co.uk) by pih-relay04.plus.net with esmtp (Exim) id 1FTFjW-0006CG-Oo; Tue, 11 Apr 2006 11:04:26 +0100 Received: from mainbox.archonet.com (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id 1419973652; Tue, 11 Apr 2006 11:06:05 +0100 (BST) Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 697F715EA4; Tue, 11 Apr 2006 11:04:26 +0100 (BST) Message-ID: <443B7F29.80807@archonet.com> Date: Tue, 11 Apr 2006 11:04:25 +0100 From: Richard Huxton User-Agent: Thunderbird 1.5 (X11/20051201) MIME-Version: 1.0 To: Rajesh Kumar Mallah Cc: Simon Dale , pgsql-performance@postgresql.org Subject: Re: Stored Procedure Performance References: <416F947BF5BA9E40B5F9AA649422212E074DE930@ex-mail2.internal.rmplc.net> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Archive-Number: 200604/230 X-Sequence-Number: 18314 Rajesh Kumar Mallah wrote: > 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 and >> I was wondering if it is usual for stored procedures to perform slower on >> PostgreSQL than raw SQL? > > No. > > RETURN NEXT keeps accumulating the data before returning. > I am not sure if any optimisations have been done to that effect. > > In general functions are *NOT* slower than RAW SQL. Actually, in cases where there is a simple way to state the query in raw SQL then I'd expect that a procedural solution IS slower. After all, you're adding another layer of processing. Of course, you normally wouldn't write a procedural solution to a simple query. Added to this is the difference that plpgsql is planned once whereas raw sql will be planned on each query. This means you save planning costs with the plpgsql but have the chance to get better plans with the raw sql. -- Richard Huxton Archonet Ltd