I need more information about the cursors. Is there any performance impact using cursors in stored procedure?
Asked
Active
Viewed 240 times
0
-
4Cursors are in general, always slower than processing via set logic. If they can be avoided they should be for performance. However, at times row-by-row processing simply can't be avoided, in which cases, cursors are the way to go vs pulling data back to a server, manipulating it and then updating. – xQbert Jul 29 '14 at 13:06
-
http://stackoverflow.com/questions/287445/why-do-people-hate-sql-cursors-so-much – Dave Markle Jul 29 '14 at 13:13
1 Answers
4
Cursors are one of the worst things you can do for performance. They run row by row instead of impacting the whole set of data. No one except an experienced dba should ever consider writing one.
http://wiki.lessthandot.com/index.php/Cursors_and_How_to_Avoid_Them

Dave Markle
- 95,573
- 20
- 147
- 170

HLGEM
- 94,695
- 15
- 113
- 186
-
There are times and places to use them though once you have the experience to know how much impact they have: http://stackoverflow.com/questions/1479680/ms-sql-server-when-is-a-cursor-good/1479751#1479751 – HLGEM Jul 29 '14 at 13:17
-
1I agree with HLGEM but read @xQbert comment. If its unavoidable give a look at the "fast_forward" option at declaring cursors – jean Jul 29 '14 at 13:49