Oh man, as a dba, I can’t help but reply
There are some things you simply can’t do efficiently unless you do it
on the DB. I think too often people get afraid of being forced to stick
with one DB, when in reality you probably wont switch anyway.
Since the Db is actually interpreting the TSQL code being thrown at it
and making its best guess about how to use indexes, etc. stored
procedures are particularly useful for forcing a compiler to work one
way or another. In addition, with large tables, or queries that require
complex logic, you simply cannot do it on the client side with any
efficiency.
I feel better
-B
PS: I love this example… Most people aren’t aware that the join order
can effect the query time.
-
Take this query.
Select * from large_table lt join small_table st on lt.id=ct.id -
On most RBDMS systems you can make it more efficient by simply
switching the join order.
Select * from small_table st join large_table lt on lt.id=ct.id