On Nov 27, 2007 1:57 AM, Alagu Madhu <almadhu@xxxxxxxxx> 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. :) ---------------------------(end of broadcast)--------------------------- TIP 4: Have you searched our list archives? http://archives.postgresql.org/