Skip to content

Latest commit

 

History

History
63 lines (52 loc) · 3.75 KB

File metadata and controls

63 lines (52 loc) · 3.75 KB
title sys.query_store_plan_forcing_locations (Transact-SQL)
description The sys.query_store_plan_forcing_locations system view contains information about where Query Store plans have been forced on secondary replicas.
author MikeRayMSFT
ms.author mikeray
ms.date 11/17/2025
ms.service sql
ms.subservice system-objects
ms.topic reference
f1_keywords
SYS.query_store_plan_forcing_locations_TSQL
query_store_plan_forcing_locations_TSQL
SYS.query_store_plan_forcing_locations
query_store_plan_forcing_locations
helpviewer_keywords
query_store_plan_forcing_locations catalog view
sys.query_store_plan_forcing_locations catalog view
dev_langs
TSQL
monikerRange >=sql-server-ver16||>=sql-server-linux-ver16||=azuresqldb-current

sys.query_store_plan_forcing_locations (Transact-SQL)

[!INCLUDE sqlserver2025-asdb]

Contains information about Query Store plans that have been forced on secondary replicas using sp_query_store_force_plan, when Query Store for secondary replicas is enabled. You can use this information to determine what queries have plans forced on different replica sets.

Query Store for secondary replicas is supported starting in [!INCLUDE sssql25-md] and later versions, and in Azure SQL Database. For complete platform support, see Query Store for secondary replicas.

Column name Data type Description
plan_forcing_location_id bigint System-assigned ID for this plan forcing location.
query_id bigint References query_id in sys.query_store_query
plan_id bigint References plan_id in sys.query_store_plan
replica_group_id bigint From the parameter force_plan_scope in sp_query_store_force_plan (Transact-SQL). References replica_group_id in sys.query_store_replicas

Permissions

Requires the VIEW DATABASE STATE permission.

Example

Use sys.query_store_plan_forcing_locations, joined with sys.query_store_replicas, to retrieve Query Store plans forced on all secondary replicas.

SELECT query_plan 
FROM sys.query_store_plan AS qsp
    INNER JOIN sys.query_store_plan_forcing_locations AS pfl 
        ON pfl.query_id = qsp.query_id 
    INNER JOIN sys.query_store_replicas AS qsr
        ON qsr.replica_group_id = qsp.replica_group_id
WHERE qsr.replica_name = 'yourSecondaryReplicaName';

Related content