tag:blogger.com,1999:blog-3635447662505002071.post3995727876303113450..comments2022-03-31T03:30:53.887+01:00Comments on Database Science: Stored Procedures Are Slow Part 2dbsciencehttp://www.blogger.com/profile/05472838753270367869noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-3635447662505002071.post-72397716595519218222009-04-02T14:02:00.000+01:002009-04-02T14:02:00.000+01:00I stated in the article "No one would actually wri...I stated in the article "No one would actually write this code when a simple SQL alternative is possible". It was a simple example designed to show an example of cursors being very slow. <BR/><BR/>To understand the need for this article see the comments in part 1 where people suggest to do this as they didn't understand stored procs were so slow. <BR/><BR/>Still, there are cases where problems can't be easily solved using set logic and procedural logic is the better solution, as I also stated in the article. In those cases a stored proc cursor is slow and one might want to explore alternatives. <BR/><BR/>You might also want to see the next article "Is SQL Slow?", as there are cases where SQL is far slower than C# or Java code. I'm not stating anything new here as Ralph Kimball pointed this out a long time ago.dbsciencehttps://www.blogger.com/profile/05472838753270367869noreply@blogger.comtag:blogger.com,1999:blog-3635447662505002071.post-65143665389977219622009-04-02T11:03:00.000+01:002009-04-02T11:03:00.000+01:00Is this a serious post? Why would you use a cursor...Is this a serious post? <BR/><BR/>Why would you use a cursor for this? Cursors are a legacy element of SQL that should not be used in modern code. By using a cursor you prevent the database from optimizing the execution of the query.<BR/><BR/>The whole point of SQL is to state what you want to get and let the database find the best way to get it. It doesn't alway get it right but a cursor *never* will.<BR/><BR/>Not trying to be a troll here... but if your background is object oriented programming I suggest you do some research on set theory. <BR/><BR/>OR just read any book by Joe Celko.Joe Harrishttp://vintage76.tumblr.comnoreply@blogger.com