Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Transact SQL Cursors

Author  Topic 

PeterG
Posting Yak Master

156 Posts

Posted - 2003-01-08 : 15:58:09
Inherited a site with most stored procs written using cursors. Am not sure whether or not to rewrite them without using cursors. I've read a few articles on this site about cursor's slow performance. Also I've noticed that a lot of gurus (if not all) on this site does not advocate the use of cursors. What other problems do using cursors present?

royv
Constraint Violating Yak Guru

455 Posts

Posted - 2003-01-08 : 16:26:18
I also have had locking issues with cursors which resulted in the database crashing. I HIGHLY suggest you look through the code not only for performance, but to make sure cursors are appropriately being released and deallocated. If not, you WILL have problems. As this site recommends, rewriting them is what I recommend.

***************************************
Death must absolutely come to enemies of the code!
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2003-01-08 : 16:52:53
The biggest drawback with cursors is that, essentially, you ignore all of the things that SQL Server can do to optimize a query. Indexes might be used, but the rows are processed sequentially afterwards, so there's no performance benefit there. Pick your analogy: would you rather:

- find a needle in a haystack using a) tweezers (cursors) or b) a magnet (SQL)?
- put sugar in your coffee/tea using a) tweezers (cursors) or b) a spoon (SQL)?

Go to Top of Page
   

- Advertisement -