Re: Stored Procedures vs Dynamic SQL generated by ORM ? - Mailing list pgsql-general

From Scott Marlowe
Subject Re: Stored Procedures vs Dynamic SQL generated by ORM ?
Date
Msg-id dcc563d10711270930j2f553c5eg6e11f3950ee80813@mail.gmail.com
Whole thread Raw
In response to Stored Procedures vs Dynamic SQL generated by ORM ?  (Alagu Madhu <almadhu@gmail.com>)
List pgsql-general
On Nov 27, 2007 1:57 AM, Alagu Madhu <almadhu@gmail.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. :)

pgsql-general by date:

Previous
From: "Scott Marlowe"
Date:
Subject: Re: Non-unique values problem after 'add column'
Next
From: Andrew Sullivan
Date:
Subject: Re: Stored Procedures vs Dynamic SQL generated by ORM ?