Skip to content

Latest commit

 

History

History
67 lines (51 loc) · 2.57 KB

sp-query-store-flush-db-transact-sql.md

File metadata and controls

67 lines (51 loc) · 2.57 KB
title description author ms.author ms.reviewer ms.date ms.service ms.subservice ms.topic f1_keywords helpviewer_keywords dev_langs monikerRange
sp_query_store_flush_db (Transact-SQL)
Flushes the in-memory portion of the Query Store data to disk.
markingmyname
maghan
randolphwest
08/21/2024
sql
system-objects
reference
sp_query_store_flush_db_TSQL
sys.sp_query_store_flush_db_TSQL
sp_query_store_flush_db
sys.sp_query_store_flush_db
sys.sp_query_store_flush_db
sp_query_store_flush_db
TSQL
=azuresqldb-current || >=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current

sp_query_store_flush_db (Transact-SQL)

[!INCLUDE sqlserver2016-asdb-asdbmi]

Flushes the in-memory portion of the Query Store data to disk.

:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions

Syntax

sp_query_store_flush_db
[ ; ]

Return code values

0 (success) or 1 (failure).

Remarks

If Query Store for secondary replicas is enabled, when sys.sp_query_store_flush_db is executed on a secondary replica, that secondary replica's cache is forced to flush to the cache on the primary replica. This can accelerate the Query Store cache data being synced to the primary replica, if the secondary replica cache flush is otherwise delayed under heavy workload.

Permissions

Requires the ALTER permission on the database.

Examples

The following example flushes the in-memory portion of the Query Store data to disk.

EXEC sp_query_store_flush_db;

Related content