Skip to content

Latest commit

 

History

History
74 lines (55 loc) · 2.67 KB

File metadata and controls

74 lines (55 loc) · 2.67 KB
title sp_query_store_flush_db (Transact-SQL)
description Flushes the in-memory portion of the Query Store data to disk.
author markingmyname
ms.author maghan
ms.reviewer randolphwest
ms.date 06/23/2025
ms.service sql
ms.subservice system-objects
ms.topic reference
ms.custom
ignite-2025
f1_keywords
sp_query_store_flush_db_TSQL
sys.sp_query_store_flush_db_TSQL
sp_query_store_flush_db
sys.sp_query_store_flush_db
helpviewer_keywords
sys.sp_query_store_flush_db
sp_query_store_flush_db
dev_langs
TSQL
monikerRange =azuresqldb-current || >=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current || =fabric-sqldb

sp_query_store_flush_db (Transact-SQL)

[!INCLUDE sqlserver2016-asdb-asdbmi-fabricsqldb]

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
[ ; ]

Arguments

None.

Return code values

0 (success) or 1 (failure).

Remarks

If Query Store for readable secondaries 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.

EXECUTE sp_query_store_flush_db;

Related content