Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

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 tmp
    WHERE 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 tmp
    WHERE 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.

The complete script to update the data collector stored procedure can also be found in the following blog:

http://blogs.msdn.com/b/sqlagent/archive/2011/04/12/data-collector-s-sp-purge-data-may-run-for-hours-if-there-are-many-orphaned-plans-to-purge.aspx


Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Was this information helpful?

What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×