Chapter 14

image

Cursor Cost Analysis

It is very common to find database applications that use cursors to process one row at a time. Because data manipulation through a cursor in SQL Server incurs significant additional overhead, database applications should avoid using cursors. T-SQL and SQL Server are designed to work best with sets of data, not one row at a time. Jeff Moden famously termed this type of processing RBAR (pronounced, ree-bar), meaning Row By Agonizing Row. However, if a cursor must be used, then use a cursor with the least cost.

In this chapter, I cover the following topics:

  • The fundamentals of cursors
  • A cost analysis of different ...

Get SQL Server 2012 Query Performance Tuning, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.