Szerkesztés

Megosztás a következőn keresztül:


sp_query_store_reset_exec_stats (Transact-SQL)

Applies to: SQL Server 2016 (13.x) and later Azure SQL Database Azure SQL Managed Instance

Clears the runtime stats for a specific query plan from the Query Store. If you enable Query Store for secondary replicas, sp_query_store_reset_exec_stats can only be executed against the primary replica. The procedure's scope applies to the entire replica set.

Transact-SQL syntax conventions

Syntax

sp_query_store_reset_exec_stats [ @plan_id = ] plan_id
[ ; ]

Arguments

[ @plan_id = ] plan_id

The ID of the query plan to be cleared. @plan_id is bigint, with no default.

Return code values

0 (success) or 1 (failure).

Permissions

Requires the ALTER permission on the database.

Examples

The following example returns information about the queries in the Query Store.

SELECT txt.query_text_id,
    txt.query_sql_text,
    pl.plan_id,
    qry.*
FROM sys.query_store_plan AS pl
INNER JOIN sys.query_store_query AS qry
    ON pl.query_id = qry.query_id
INNER JOIN sys.query_store_query_text AS txt
    ON qry.query_text_id = txt.query_text_id;

After you identify the plan_id that you want to clear the statistics, use the following example to delete the execution stats for a specific query plan. This example deletes the execution stats for plan number 3.

EXEC sp_query_store_reset_exec_stats 3;