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 70C9411F644F for ; Tue, 11 Apr 2006 11:09:03 -0300 (ADT) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Score: 1.467 X-Spam-Level: * X-Spam-Status: No, score=1.467 required=5 tests=[AWL=-0.452, DNS_FROM_RFC_ABUSE=0.479, DNS_FROM_RFC_POST=1.44] Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id MjbcsbxMrMo2 for ; Tue, 11 Apr 2006 11:08:55 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mx2.surnet.cl (mx2.surnet.cl [216.155.73.181]) by postgresql.org (Postfix) with ESMTP id D1A3F11F6405 for ; Tue, 11 Apr 2006 11:08:58 -0300 (ADT) Received: from unknown (HELO cluster.surnet.cl) ([216.155.73.165]) by mx2.surnet.cl with ESMTP; 11 Apr 2006 10:08:58 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AQAAAE6QIkSICgIC X-IronPort-AV: i="4.02,198,1139194800"; d="scan'208"; a="42322237:sNHT16884432" Received: from alvh.no-ip.org (201.221.200.14) by cluster.surnet.cl (7.0.043) (authenticated as alvherre@surnet.cl) id 443B7DDC00009CB5; Tue, 11 Apr 2006 10:08:57 -0400 Received: by alvh.no-ip.org (Postfix, from userid 1000) id 02A23C2DC22; Tue, 11 Apr 2006 10:08:58 -0400 (CLT) Date: Tue, 11 Apr 2006 10:08:57 -0400 From: Alvaro Herrera To: Merlin Moncure Cc: Simon Dale , pgsql-performance@postgresql.org Subject: Re: Stored Procedure Performance Message-ID: <20060411140857.GE11760@surnet.cl> Mail-Followup-To: Merlin Moncure , Simon Dale , pgsql-performance@postgresql.org References: <416F947BF5BA9E40B5F9AA649422212E074DE930@ex-mail2.internal.rmplc.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.11+cvs20060330 X-Archive-Number: 200604/238 X-Sequence-Number: 18322 Merlin Moncure 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? > > pl/pgsql procedures are a very thin layer over the query engine. > 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. There's one problem that hasn't been mentioned. For the optimizer a PL/pgSQL function (really, a function in any language except SQL) is a black box. If you have a complex join of two or three functions, and they don't return 1000 rows, it's very likely that the optimizer is going to get it wrong. -- Alvaro Herrera http://www.CommandPrompt.com/ The PostgreSQL Company - Command Prompt, Inc.