FIX: When you run a query that uses the NOLOCK table hint in SQL Server 2005 or in SQL Server 2008 to retrieve BLOB data, the query runs very slowly

Extended support for SQL Server 2005 ended on April 12, 2016

If you are still running SQL Server 2005, you will no longer receive security updates and technical support. We recommend upgrading to SQL Server 2014 and Azure SQL Database to achieve breakthrough performance, maintain security and compliance, and optimize your data platform infrastructure. Learn more about the options for upgrading from SQL Server 2005 to a supported version here.

Microsoft distributes Microsoft SQL Server 2005 fixes as one downloadable file. Because the fixes are cumulative, each new release contains all the hotfixes and all the security fixes that were included with the previous SQL Server 2005 fix release.
Microsoft distributes Microsoft SQL Server 2008 fixes as one downloadable file. Because the fixes are cumulative, each new release contains all the hotfixes and all the security fixes that were included with the previous SQL Server 2008 fix release.
SYMPTOMS
You have a query that uses the NOLOCK table hint in Microsoft SQL Server 2005 or in Microsoft SQL Server 2008. The query reads binary large object (BLOB) data of one of the following data types from a large table:
  • The Text data type
  • The nText data type
  • The Image data type
When you run the query, the query runs very slowly. If you examine the disk activity that the query generates, you notice that the number of logical reads is very high.

Note To display the disk activities, run the query by using the SET STATISTICS IO ON clause.
CAUSE
When the query that uses the NOLOCK table hint reads BLOB data, SQL Server verifies that each BLOB page is allocated by examining the corresponding index allocation map (IAM). The IAM is a linked list of allocation pages. Each IAM page can hold approximately 4 GB of data (8 KB page size * 8 pages * 64,000 extents). If the object is large, the verification operation can lead to excessive logical reads.

For example, you have a large object mapped to a file group. The total size of files in the file group is 700 GB. In this situation, the IAM for this object can contain up to 175 pages. If you now run a query on this object by using the NOLOCK table hint, and the query accesses 10,000 BLOB pages, the number of logical reads that are related to IAM pages will be 175 * 10,000 = 1,750,000 in the worst case. If SQL Server finds the corresponding IAM page by traversing half of the linked list, the average number of logical reads that are related to IAM pages will be approximately 1,750,000 / 2 = 875,000. This is too high an overhead to incur for a query to access 10,000 BLOB pages.
RESOLUTION

Cumulative update information for SQL Server 2005

The fix for this issue was first released in Cumulative Update 3 for SQL Server 2005 Service Pack 3. For more information about how to obtain this cumulative update package for SQL Server 2005, click the following article number to view the article in the Microsoft Knowledge Base:
967909 Cumulative update package 3 for SQL Server 2005 Service Pack 3
Note Because the builds are cumulative, each new fix release contains all the hotfixes and all the security fixes that were included with the previous SQL Server 2005 fix release. We recommend that you consider applying the most recent fix release that contains this hotfix. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
960598 The SQL Server 2005 builds that were released after SQL Server 2005 Service Pack 3 was released

Cumulative update information for SQL Server 2008

The fix for this issue was first released in Cumulative Update 5 for SQL Server 2008. For more information about how to obtain this cumulative update package for SQL Server 2008, click the following article number to view the article in the Microsoft Knowledge Base:
969531 Cumulative update package 5 for SQL Server 2008
Note Because the builds are cumulative, each new fix release contains all the hotfixes and all the security fixes that were included with the previous SQL Server 2008 fix release. We recommend that you consider applying the most recent fix release that contains this hotfix. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
956909 The SQL Server 2008 builds that were released after SQL Server 2008 was released
STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.
MORE INFORMATION
The fix for this problem uses the IAM cache to quickly determine whether a BLOB page is actually allocated.

For more information about what files are changed, and for information about any prerequisites to apply the cumulative update package that contains the hotfix that is described in this Microsoft Knowledge Base article, click the following article number to view the article in the Microsoft Knowledge Base:
967909 Cumulative update package 3 for SQL Server 2005 Service Pack 3
For more information about what files are changed, and for information about any prerequisites to apply the cumulative update package that contains the hotfix that is described in this Microsoft Knowledge Base article, click the following article number to view the article in the Microsoft Knowledge Base:
969531 Cumulative update package 5 for SQL Server 2008
REFERENCES
For more information about the list of builds that are available after SQL Server 2005 Service Pack 3, click the following article number to view the article in the Microsoft Knowledge Base:
960598 The SQL Server 2005 builds that were released after SQL Server 2005 Service Pack 3 was released
For more information about the list of builds that are available after SQL Server 2008, click the following article number to view the article in the Microsoft Knowledge Base:
956909 The SQL Server 2008 builds that were released after SQL Server 2008 was released
For more information about the Incremental Servicing Model for SQL Server, click the following article number to view the article in the Microsoft Knowledge Base:
935897 An Incremental Servicing Model is available from the SQL Server team to deliver hotfixes for reported problems
For more information about the naming schema for SQL Server updates, click the following article number to view the article in the Microsoft Knowledge Base:
822499 New naming schema for Microsoft SQL Server software update packages
For more information about software update terminology, click the following article number to view the article in the Microsoft Knowledge Base:
824684 Description of the standard terminology that is used to describe Microsoft software updates
Properties

Article ID: 961049 - Last Review: 05/18/2009 23:00:42 - Revision: 3.0

Microsoft SQL Server 2005 Developer Edition, Microsoft SQL Server 2005 Enterprise Edition, Microsoft SQL Server 2005 Standard Edition, Microsoft SQL Server 2005 Standard X64 Edition, Microsoft SQL Server 2005 Enterprise X64 Edition, Microsoft SQL Server 2005 Enterprise Edition for Itanium-based Systems, Microsoft SQL Server 2005 Standard Edition for Itanium-based Systems, Microsoft SQL Server 2005 Workgroup Edition, Microsoft SQL Server 2008 Developer, Microsoft SQL Server 2008 Enterprise, Microsoft SQL Server 2008 Standard, Microsoft SQL Server 2008 Web, Microsoft SQL Server 2008 Workgroup

  • kbsurveynew kbhotfixrollup kbfix kbqfe kbexpertiseadvanced KB961049
Feedback