Re: Stored Procedure Performance

From: Richard Huxton <dev(at)archonet(dot)com>
To: Rajesh Kumar Mallah <mallah(dot)rajesh(at)gmail(dot)com>
Cc: Simon Dale <sdale(at)rm(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: Stored Procedure Performance
Date: 2006-04-11 10:04:25
Message-ID: 443B7F29.80807@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Rajesh Kumar Mallah wrote:
> On 4/11/06, Simon Dale <sdale(at)rm(dot)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

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Richard Huxton 2006-04-11 10:17:01 Re: Takes too long to fetch the data from database
Previous Message Rajesh Kumar Mallah 2006-04-11 08:22:48 Re: Stored Procedure Performance