Skip to content

Commit 7eb5d41

Browse files
20251118 query store for secondary replicas (#35847)
1 parent b089dcf commit 7eb5d41

16 files changed

Lines changed: 107 additions & 56 deletions

docs/database-engine/configure-windows/configure-windows-service-accounts-and-permissions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Most services and their properties can be configured by using SQL Server Configu
2424

2525
| SQL Server version | Path |
2626
| --- | --- |
27-
| [!INCLUDE [sssql25-md](../../includes/sssql22-md.md)] | `C:\Windows\SysWOW64\SQLServerManager17.msc` |
27+
| [!INCLUDE [sssql25-md](../../includes/sssql25-md.md)] | `C:\Windows\SysWOW64\SQLServerManager17.msc` |
2828
| [!INCLUDE [sssql22-md](../../includes/sssql22-md.md)] | `C:\Windows\SysWOW64\SQLServerManager16.msc` |
2929
| [!INCLUDE [sssql19-md](../../includes/sssql19-md.md)] | `C:\Windows\SysWOW64\SQLServerManager15.msc` |
3030
| [!INCLUDE [sssql17-md](../../includes/sssql17-md.md)] | `C:\Windows\SysWOW64\SQLServerManager14.msc` |

docs/relational-databases/performance/intelligent-query-processing-cardinality-estimation-feedback.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ If a query has a query plan forced through Query Store, CE feedback isn't used f
134134

135135
If a query uses hard-coded query hints or is using Query Store hints set by the user, CE feedback isn't used for that query. For more information, see [Query hints](../../t-sql/queries/hints-transact-sql-query.md) and [Query Store hint](query-store-hints.md).
136136

137-
Starting with [!INCLUDE [sssql22-md](../../includes/sssql22-md.md)], when Query Store for secondary replicas is enabled, CE feedback isn't replica-aware for secondary replicas in availability groups. CE feedback currently only benefits primary replicas. On failover, feedback applied to primary or secondary replicas is lost. For more information, see [Query Store for secondary replicas](query-store-for-secondary-replicas.md).
137+
Starting with [!INCLUDE [sssql22-md](../../includes/sssql22-md.md)], when Query Store for secondary replicas is enabled, CE feedback isn't replica-aware for secondary replicas in availability groups. CE feedback currently only benefits primary replicas. On failover, feedback applied to primary or secondary replicas is lost. The Query Store is available on secondary availability group replicas starting in [!INCLUDE [sssql25-md](../../includes/sssql25-md.md)]. For more information, see [Query Store for secondary replicas](query-store-for-secondary-replicas.md).
138138

139139
## Persistence for cardinality estimation (CE) feedback
140140

docs/relational-databases/performance/intelligent-query-processing-degree-parallelism-feedback.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Only verified feedback is persisted. If the adjusted DOP results in a performanc
6363
6464
Stable feedback is reverified upon plan recompilation and might readjust up or down, but never higher than the MAXDOP setting (including a MAXDOP hint).
6565
66-
Starting with [!INCLUDE [sssql22-md](../../includes/sssql22-md.md)], when Query Store for secondary replicas is enabled, DOP feedback is also replica-aware for secondary replicas in availability groups. DOP feedback can apply feedback differently on a primary replica and on a secondary replica. However, DOP feedback is not persisted on secondary replicas, and on failover, the DOP feedback from the old primary replica is not applied to the new primary replica. On failover, feedback applied to primary or secondary replicas is lost. For more information, see [Query Store for secondary replicas](query-store-for-secondary-replicas.md).
66+
Starting with [!INCLUDE [sssql22-md](../../includes/sssql22-md.md)], when Query Store for secondary replicas is enabled, DOP feedback is also replica-aware for secondary replicas in availability groups. DOP feedback can apply feedback differently on a primary replica and on a secondary replica. However, DOP feedback is not persisted on secondary replicas, and on failover, the DOP feedback from the old primary replica is not applied to the new primary replica. On failover, feedback applied to primary or secondary replicas is lost. The Query Store is available on secondary availability group replicas starting in [!INCLUDE [sssql25-md](../../includes/sssql25-md.md)]. For more information, see [Query Store for secondary replicas](query-store-for-secondary-replicas.md).
6767
6868
### Degree of parallelism (DOP) feedback implementation
6969

docs/relational-databases/performance/intelligent-query-processing-memory-grant-feedback.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ Given feedback data is now persisted in the Query Store, there's some increase i
260260

261261
Percentile-based memory grant errs on the side of reducing spills. Because it's no longer based on the last execution-only but on an observation of the several past executions, this could increase memory usage for oscillating workloads with wide variance in memory grant requirements between executions.
262262

263-
Starting with [!INCLUDE [sssql22-md](../../includes/sssql22-md.md)], when Query Store for secondary replicas is enabled, memory grant feedback is replica-aware for secondary replicas in availability groups. Memory grant feedback can apply feedback differently on a primary replica and on a secondary replica. However, memory grant feedback is not persisted on secondary replicas, and on failover, the memory grant feedback from the old primary replica is applied to the new primary replica. Any feedback applied to the secondary replica when it becomes the primary replica is lost. For more information, see [Query Store for secondary replicas](query-store-for-secondary-replicas.md).
263+
Starting with [!INCLUDE [sssql22-md](../../includes/sssql22-md.md)], when Query Store for secondary replicas is enabled, memory grant feedback is replica-aware for secondary replicas in availability groups. Memory grant feedback can apply feedback differently on a primary replica and on a secondary replica. However, memory grant feedback is not persisted on secondary replicas, and on failover, the memory grant feedback from the old primary replica is applied to the new primary replica. Any feedback applied to the secondary replica when it becomes the primary replica is lost. The Query Store is available on secondary availability group replicas starting in [!INCLUDE [sssql25-md](../../includes/sssql25-md.md)]. For more information, see [Query Store for secondary replicas](query-store-for-secondary-replicas.md).
264264

265265
## Related content
266266

docs/relational-databases/performance/monitoring-performance-by-using-the-query-store.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,11 @@ ON Pln.plan_id = RtSt.plan_id;
131131

132132
## Query Store for secondary replicas
133133

134-
**Applies to:** [!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)] (Starting with [!INCLUDE [sql-server-2022](../../includes/sssql22-md.md)])
134+
**Applies to:** [!INCLUDE [sql-server-2025](../../includes/sssql25-md.md)], Azure SQL Database
135135

136136
The Query Store for secondary replicas feature enables the same Query Store functionality on secondary replica workloads that is available for primary replicas. When Query Store for secondary replicas is enabled, replicas send the query execution information that would normally be stored in the Query Store back to the primary replica. The primary replica then persists the data to disk within its own Query Store. In essence, there's one Query Store shared between the primary and all secondary replicas. The Query Store exists on the primary replica and stores data for all replicas together.
137137

138-
For complete information on Query Store for secondary replicas, see [Query Store for readable secondaries](query-store-for-secondary-replicas.md).
138+
For more information, see [Query Store for secondary replicas](query-store-for-secondary-replicas.md).
139139

140140
<a id="Regressed"></a>
141141

docs/relational-databases/performance/persisted-stats-secondary-replicas.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@ ms.topic: concept-article
1010
ms.custom:
1111
- ignite-2025
1212
# customer intent: As a data engineer, I want statistics that are created on readable secondaries to be persisted so that my workloads that are running against secondary replicas are optimized.
13+
monikerRange: "=azuresqldb-current || >=sql-server-ver17 || >=sql-server-linux-ver17"
1314
---
1415

1516
# Persisted statistics for readable secondaries
1617

17-
**Applies to:** [!INCLUDE [sqlserver2025-asdb-fabricsqldb](../../includes/applies-to-version/sqlserver2025-asdb-fabricsqldb.md)]
18+
**Applies to:** [!INCLUDE [sqlserver2025-asdb](../../includes/applies-to-version/sqlserver2025-asdb.md)]
1819

19-
[Query Store for readable secondaries](query-store-for-secondary-replicas.md) was introduced in [!INCLUDE [sssql22-md](../../includes/sssql22-md.md)], and the persisted statistics for readable secondaries feature uses the infrastructure that Query Store has in place for readable secondaries. Query Store for readable secondaries is **on** by default in [!INCLUDE [sssql25-md](../../includes/sssql25-md.md)], whereas in [!INCLUDE [sssql22-md](../../includes/sssql22-md.md)] it was **off** and required trace flag 12606 to enable.
20+
[Query Store for readable secondaries](query-store-for-secondary-replicas.md) is available in [!INCLUDE [sssql25-md](../../includes/sssql25-md.md)] and Azure SQL Database, and the persisted statistics for readable secondaries feature uses the infrastructure that Query Store has in place for readable secondaries.
2021

21-
Trace flag 12606 **isn't** required on [!INCLUDE [sssql25-md](../../includes/sssql25-md.md)] and later versions and if used, result in turning the Query Store for readable secondaries feature *off*.
22+
Query Store for readable secondaries is **on** by default in [!INCLUDE [sssql25-md](../../includes/sssql25-md.md)] and Azure SQL Database.
2223

2324
## Background
2425

@@ -27,6 +28,7 @@ On readable secondary replicas, statistics can also be automatically created whe
2728
When the Database Engine creates temporary statistics, the statistics name is appended with the suffix `_readonly_database_statistic` to differentiate the temporary statistics from the permanent statistics. The suffix `_readonly_database_statistic` is reserved for statistics generated by SQL Server. The reason that this approach was taken was to address workloads that execute against readable secondary replicas that might require distinct statistics that don't exist on the primary replica.
2829

2930
Temporary statistics created on secondary replicas remain visible only to the replica that generated them. The primary replica never directly accesses these temporary statistics objects and is only aware of the permanent statistics object after persistence. When temporary statistics are persisted to the primary replica, they become available to all replicas in the availability group through the synchronization mechanism.
31+
3032
The persistence mechanism uses the Query Store for readable secondaries infrastructure introduced in [!INCLUDE [sssql22-md](../../includes/sssql22-md.md)]. Statistics information is sent to the primary replica where it's persisted as permanent statistics, then synchronized back to all secondary replicas. This process occurs automatically without requiring manual intervention.
3133

3234
## Support catalog views
@@ -97,8 +99,6 @@ ORDER BY sch.[name], obj.[name], s.stats_id;
9799
## Considerations
98100

99101
The persisted statistics for readable secondaries feature is enabled by default as long as the [auto create statistics](../../t-sql/statements/alter-database-transact-sql-set-options.md) option is enabled and the `READABLE_SECONDARY_TEMPORARY_STATS_AUTO_CREATE` and `READABLE_SECONDARY_TEMPORARY_STATS_AUTO_UPDATE` database scoped configuration options are enabled, which is the default configuration. There's no database-scoped configuration to toggle the feature on and off.
100-
<!-- however, to disable the persistence of statistics from secondary for SQL Server, trace flag 15608 might be enabled at startup, or used as a global trace flag.
101-
-->
102102

103103
## Related content
104104

0 commit comments

Comments
 (0)