適用於: SQL Server 2025 (17.x)
Azure SQL Database
包含使用 sp_query_store_force_plan 強制強制安裝於次要副本的查詢庫計畫資訊,當次要副本啟用查詢庫時。 您可以使用這項資訊來判斷哪些查詢在不同的副本集上強制執行計劃。
自 SQL Server 2025(17.x)及以後版本起,以及 Azure SQL 資料庫,支援次要副本的查詢儲存庫。 欲獲得完整的平台支援,請參閱 查詢商店中的次要副本。
| 資料行名稱 | 資料類型 | 描述 |
|---|---|---|
plan_forcing_location_id |
bigint | 此計劃強制位置的系統指派標識碼。 |
query_id |
bigint | sys.query_store_query中的參考query_id |
plan_id |
bigint | sys.query_store_plan中的參考plan_id |
replica_group_id |
bigint | 從 sp_query_store_force_plan (Transact-SQL)force_plan_scope參數。 sys.query_store_replicas 中的參考replica_group_id |
權限
需要 VIEW DATABASE STATE 權限。
範例
使用 sys.query_store_plan_forcing_locations聯結sys.query_store_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';