A hidden IO performance killer in forwarded Record:sql server

Source: Internet
Author: User

Brief introduction

Recently, a customer has noticed a high counter (forwarded records/sec), with intermittent disk wait queue fluctuations. This article shares what is the forwarded record and discusses in principle why the forwarded record creates additional IO.

Storage principle

In SQL Server, when data is stored as a heap, the data is unordered, and pointers to all nonclustered indexes hold the RID that points to the physical address. When a variable-length column in a data row grows so that an existing page cannot hold a row of data, the data is moved to a new page and a pointer to a new page is left in the original location because the pointer to all nonclustered indexes does not change when an update is made to the record. As shown in Figure 1.

Figure 1. Forwarded record indicating

This is due to data update, only in the original position left pointer to the new data page storage location line, is called the forwarded record.

More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/database/SQLServer/

How does the forwarded record affect IO performance?

So why does the forwarded record cause performance problems, since it's a mechanism for improving performance? The original purpose of the forwarded record is to update the heap table so that the change in the storage location on the heap table does not update the nonclustered index at the same time overhead. But for lookups, whether a table scan exists on a heap table, or a bookmark lookup, the extra IO overhead is multiplied, as shown in the following example.

Createtabledbo.heaptest (id INT, col1 VARCHAR ())
    
declare@indexint
set@index= 0
Begintran while
@ index< 100000 
    BEGIN
        INSERT  intodbo.heaptest
                (ID, col1)
        VALUES  (@index, NULL)
        set@index= @index + 1

Code Listing 1. New heap table and insert 100,000 piece of data

Create a test table from code Listing 1 and loop through 100,000 data. Let's look at the number of pages that the heap table occupies, as shown in Figure 2.

Figure 2. Heap Table Space occupancy

The table is updated to allow the original row to grow and produce a forwarded record, at which point the storage of the heap table can be seen. As shown in Figure 3.

Fig. 3. Forwarded record of producing 8w+

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.