| |
 |
|
SQL Server Tips by Robin Schumacher
|
Forwarded Rows
SQL Server will move rows in a table under certain conditions. One
situation might arise when a row in a table that has a
variable-length column is updated to a larger size that will no
longer fit on its original page. When SQL Server creates a
forwarding pointer, the pointer remains in place unless one of two
things happens. The first is when a row shrinks enough to move back
to its original location. The second is when the entire database
shrinks. When a database file shrinks, SQL Server will reassign the
row identifiers, which are used as the row locators, so the shrink
process never generates forwarded rows.
At times, forwarded records can reduce performance because
additional I/O is involved to first obtain the record pointer to the
relocated row, and then the row itself. But, when does row
forwarding become a problem? For example, just because a table has
one hundred forwarded rows, does that mean a performance problem
exists? It depends. If the table has one hundred rows in it, a
problem does exist because 100% of the table suffers from forwarded
rows. If the table has three million rows, the forwarded row
situation involving one hundred rows is likely not causing much fuss
in the database.
The fragmentation diagnostic procedures supplied earlier in this
chapter will help the DBA identify tables with forwarded row
problems. The same holds true for the new SQL Server 2005
sys.dm_db_index_physical_stats function. In particular, the
procedures provide both a forwarded record count and a forwarded
record percent so tables that could benefit from being reorganized
can be easily pinpointed.
In terms of removing forwarded rows, the options include
reorganizing the table or performing a shrink of a database or
database file.
The above book excerpt is from:
High-Performance SQL Server DBA
Tuning & Optimization Secrets
ISBN:
0-9761573-6-5
Robin Schumacher
http://www.rampant-books.com/book_2005_2_sql_server_dba.htm |