You are currently offline, waiting for your internet to reconnect

FIX: Data Collector job takes a long time to clear data from an MDW database in SQL Server 2008 or SQL Server 2008 R2


Microsoft distributes Microsoft SQL Server 2008 R2 SP1 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 R2 SP1 fix release.
SYMPTOMS
Consider the following scenario:
  • A Management Data Warehouse (MDW) database has a snapshots.query_stats table that contains a large amount of data in Microsoft SQL Server 2008 or in Microsoft SQL Server 2008 R2.
  • You run the following Data Collector job to clear data from the MDW database.
    mdw_purge_data_[<MDW database name>]
In this scenario, it takes a long time for the Data Collector job to clear data.

Notes
CAUSE
This issue occurs because the mdw_purge_data job takes a long time to perform a batch-oriented clear operation if the snapshots.query_stats table contains a large amount of data.
RESOLUTION

Service pack information

SQL Server 2008

To resolve this issue in SQL Server 2008, follow these steps:
  1. Obtain the latest service pack for SQL Server 2008.

    For more information, click the following article number to view the article in the Microsoft Knowledge Base:
    968382 How to obtain the latest service pack for SQL Server 2008
  2. For an existing MDW database, you must update it by running the Configure Management Data Warehouse Wizard after you install the latest service pack for SQL Server 2008.


SQL Server 2008 R2

To resolve this issue in SQL Server 2008 R2, follow these steps:
  1. Obtain the latest service pack for SQL Server 2008 R2.

    For more information, click the following article number to view the article in the Microsoft Knowledge Base:
    2527041 How to obtain the latest service pack for SQL Server 2008 R2
  2. For an existing MDW database, you must update it by running the Configure Management Data Warehouse Wizard after you install the latest service pack for SQL Server 2008 R2
  3. Update the sp_purge_orphaned_notable_query_text stored procedure as follows:

    Existing procedure

    -- Deleting TOP N orphaned rows in query plan table by joining info from temp table variable-- This is done to speed up delete query. DELETE TOP (@delete_batch_size) snapshots.notable_query_plan FROM snapshots.notable_query_plan AS qp , #tmp_notable_query_plan AS tmpWHERE tmp.[sql_handle] = qp.[sql_handle]
    Updated procedure

    -- Deleting TOP N orphaned rows in query text table by joining info from temp table-- This is done to speed up delete query. DELETE TOP (@delete_batch_size) snapshots.notable_query_text FROM snapshots.notable_query_text AS qt, #tmp_notable_query_text AS tmpWHERE tmp.[sql_handle] = qt.[sql_handle]
    Note These changes are required to correct the text of the sp_purge_orphaned_notable_query_text stored procedure because the delete statement incorrectly references the snapshots.notable_query_plan table after you apply SQL Server 2008 R2 Service Pack 1.
STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.
MORE INFORMATION
The complete script to update the data collector stored procedure can also be found in the following blog:
Properties

Article ID: 2584903 - Last Review: 06/05/2012 16:15:00 - Revision: 5.0

  • Microsoft SQL Server 2008 Standard
  • Microsoft SQL Server 2008 Developer
  • Microsoft SQL Server 2008 Enterprise
  • Microsoft SQL Server 2008 R2 Datacenter
  • Microsoft SQL Server 2008 R2 Developer
  • Microsoft SQL Server 2008 R2 Enterprise
  • Microsoft SQL Server 2008 R2 Standard
  • kbqfe kbexpertiseadvanced kbsurveynew kbfix KB2584903
Feedback
ipt> icrosoft.com/ms.js'" + "'><\/script>");