pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: Rajesh Kumar Mallah <mallah.rajesh@gmail.com>
Cc: Simon Dale <sdale@rm.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Stored Procedure Performance
Date: Tue, 11 Apr 2006 11:04:25 +0100
Message-ID: <443B7F29.80807@archonet.com> (raw)
In-Reply-To: <a97c77030604110122o39534e83yf257801ce6bc4bd9@mail.gmail.com>
References: <416F947BF5BA9E40B5F9AA649422212E074DE930@ex-mail2.internal.rmplc.net>
	<a97c77030604110122o39534e83yf257801ce6bc4bd9@mail.gmail.com>

Rajesh Kumar Mallah wrote:
> On 4/11/06, Simon Dale <sdale@rm.com> 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



view thread (22+ messages)  latest in thread

Message-ID: <443B7F29.80807@archonet.com>
Permalink:  ../443B7F29.80807@archonet.com/
Also on:    postgresql.org/message-id/443B7F29.80807@archonet.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: dev@archonet.com, mallah.rajesh@gmail.com, sdale@rm.com
  Subject: Re: Stored Procedure Performance
  In-Reply-To: <443B7F29.80807@archonet.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox