Thread: Stored Procedures vs Dynamic SQL generated by ORM ?

Stored Procedures vs Dynamic SQL generated by ORM ?

From
Alagu Madhu
Date:
Hi All,


Which is the best Stored Procedures or Dynamic SQL generated by ORM ?



Thanks

Madhu Alagu

Re: Stored Procedures vs Dynamic SQL generated by ORM ?

From
"Scott Marlowe"
Date:
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. :)

Re: Stored Procedures vs Dynamic SQL generated by ORM ?

From
Andrew Sullivan
Date:
On Mon, Nov 26, 2007 at 11:57:37PM -0800, Alagu Madhu wrote:
> Which is the best Stored Procedures or Dynamic SQL generated by ORM ?

This is roughly similar to the question, "Is it better to travel by car,
boat, or plane?"  It rather depends on what you're trying to accomplish.

A

--
Andrew Sullivan
Old sigs will return after re-constitution of blue smoke