Re: Stored Procedures vs Dynamic SQL generated by ORM ?

From: "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>
To: "Alagu Madhu" <almadhu(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Stored Procedures vs Dynamic SQL generated by ORM ?
Date: 2007-11-27 17:30:29
Message-ID: dcc563d10711270930j2f553c5eg6e11f3950ee80813@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Nov 27, 2007 1:57 AM, Alagu Madhu <almadhu(at)gmail(dot)com> wrote:
>
> Which is the best Stored Procedures or Dynamic SQL generated by ORM ?

Depends on what you mean by best. Dynamic SQL costs more in the
planning stage because the db has to plan out each statement before
running it. However, it can consider the actual values in the queries
when creating those plans, so you get individually optimized plans for
each query. Generally speaking Stored Procs (UDFs in pgsql) use
static query / execution plans created at the time the UDF was
brought into being.

You should also considered prepared SQL from the client side as well.
Not sure if your ORM supports that or not.

Not a fan of ORM, but it's a necessary evil sometimes. :)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Andrew Sullivan 2007-11-27 17:32:19 Re: Stored Procedures vs Dynamic SQL generated by ORM ?
Previous Message Scott Marlowe 2007-11-27 17:26:04 Re: Non-unique values problem after 'add column'