Row-by-Row Processing from Cursors and Other Causes
摘要
The best way to manipulate data within SQL Server is through the use of set-based operations. However, as humans, we tend to think about data in a more row-by-row way. It’s true that Oracle uses a construct called a cursor to facilitate rapid data access. It’s not the same in SQL Server. When accessing data using cursors within SQL Server, row by row can be one of the slowest ways to work with data. Jeff Moden has famously called this type of processing “ree-bar,” abbreviated as RBAR, standing for “Row By Agonizing Row” to point out just how slow it can be. However, there is sometimes a valid purpose behind cursors, so it’s best to try to use them the right way.