Skip to content

Commit 27802e3

Browse files
Merge pull request #24534 from WilliamDAssafMSFT/20221011-iqp-feedback-replicas
20221011 iqp feedback replicas
2 parents 3afff1c + 7dcd44b commit 27802e3

28 files changed

Lines changed: 412 additions & 289 deletions

.openpublishing.redirection.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59035,6 +59035,11 @@
5903559035
"redirect_url": "/azure/azure-subscription-service-limits",
5903659036
"redirect_document_id": false
5903759037
},
59038+
{
59039+
"source_path": "docs/relational-databases/system-catalog-views/sys-plan-forcing-locations.md",
59040+
"redirect_url": "/sql/relational-databases/system-catalog-views/sys-query-store-plan-forcing-locations-transact-sql",
59041+
"redirect_document_id": false
59042+
},
5903859043
{
5903959044
"source_path": "docs/azure-data-studio/download.md",
5904059045
"redirect_url": "/sql/azure-data-studio/download-azure-data-studio",

docs/relational-databases/automatic-tuning/automatic-tuning.md

Lines changed: 48 additions & 47 deletions
Large diffs are not rendered by default.

docs/relational-databases/automatic-tuning/media/force-last-good-plan.png renamed to docs/relational-databases/automatic-tuning/media/automatic-tuning/force-last-good-plan.png

File renamed without changes.

docs/relational-databases/automatic-tuning/media/plan-choice-regression.png renamed to docs/relational-databases/automatic-tuning/media/automatic-tuning/plan-choice-regression.png

File renamed without changes.

docs/relational-databases/automatic-tuning/media/tuning-process.png renamed to docs/relational-databases/automatic-tuning/media/automatic-tuning/tuning-process.png

File renamed without changes.

docs/relational-databases/performance/intelligent-query-processing-details.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ms.reviewer: "wiassaf"
1212
ms.custom:
1313
- seo-dt-2019
1414
- event-tier1-build-2022
15-
ms.date: 07/26/2022
15+
ms.date: 11/01/2022
1616
monikerRange: "=azuresqldb-current||>=sql-server-2016||>=sql-server-linux-2017||=azuresqldb-mi-current"
1717
---
1818

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

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ The feedback features discussed in this article are:
3535

3636
## Memory grant feedback
3737

38-
Sometimes a query executes with a memory grant that is too large or too small. If the memory grant is too large, we inhibit parallelism on the server. If it's too small, we may spill to disk, which is a costly operation. Memory grant feedback attempts to remember the memory needs of a prior execution (starting in [!INCLUDE [sssql22-md](../../includes/sssql22-md.md)], multiple executions) of a query and adjust the grant given to the query accordingly. This feature has been released in three waves. Batch mode memory grant feedback, followed by row mode memory grant feedback, and in [!INCLUDE [sssql22-md](../../includes/sssql22-md.md)], we're introducing memory grant feedback on-disk persistence using the query store and an improved algorithm known as percentile grant.
39-
40-
Starting with [!INCLUDE [sssql22-md](../../includes/sssql22-md.md)], when Query Store for secondary replicas is enabled, memory grant feedback is also replica-aware for secondary replicas in availability groups. Memory grant feedback can apply feedback differently on a primary replica and on a secondary replica. For more information, see [Query Store for secondary replicas](monitoring-performance-by-using-the-query-store.md#query-store-for-secondary-replicas).
38+
Sometimes a query executes with a memory grant that is too large or too small. If the memory grant is too large, we inhibit parallelism on the server. If it's too small, we may spill to disk, which is a costly operation. Memory grant feedback attempts to remember the memory needs of a prior execution (starting in [!INCLUDE [sssql22-md](../../includes/sssql22-md.md)], multiple executions) of a query and adjust the grant given to the query accordingly. This feature has been released in three waves. Batch mode memory grant feedback, followed by row mode memory grant feedback, and in [!INCLUDE [sssql22-md](../../includes/sssql22-md.md)], we're introducing memory grant feedback on-disk persistence using the Query Store and an improved algorithm known as percentile grant.
4139

4240
### Batch mode memory grant feedback
4341

@@ -207,10 +205,12 @@ A USE HINT query hint takes precedence over a [database scoped configuration](..
207205

208206
This feature was introduced in [!INCLUDE[ssSQL22](../../includes/sssql22-md.md)], however this performance enhancement is available for queries that operate in the database compatibility level 140 (introduced in SQL Server 2017) or higher, or the QUERY_OPTIMIZER_COMPATIBILITY_LEVEL_n hint of 140 and higher, and when Query Store is enabled for the database and is in a "read write" state.
209207

210-
It's recommended that you have a performance baseline for your workload before the feature is enabled for your database. The baseline numbers will help you determine if you're getting the intended benefit from the feature.
208+
- Percentile memory grant feedback is enabled by default in [!INCLUDE[ssSQL22](../../includes/sssql22-md.md)], but has no effect if when Query Store is not enabled and in a "read write" state.
209+
- Persistence for memory grant, CE, and DOP feedback is on by default in [!INCLUDE[ssSQL22](../../includes/sssql22-md.md)], but has no effect if when Query Store is not enabled and in a "read write" state.
210+
- Percentile memory grant feedback is not currently available in [!INCLUDE[ssSDSfull](../../includes/sssdsfull-md.md)], and [!INCLUDE[ssazuremi_md](../../includes/ssazuremi_md.md)].
211+
- Persistence is not currently available in [!INCLUDE[ssSDSfull](../../includes/sssdsfull-md.md)] and [!INCLUDE[ssazuremi_md](../../includes/ssazuremi_md.md)].
211212

212-
- Percentile memory grant feedback is disabled by default in [!INCLUDE[ssSQL22](../../includes/sssql22-md.md)], [!INCLUDE[ssSDSfull](../../includes/sssdsfull-md.md)], and [!INCLUDE[ssazuremi_md](../../includes/ssazuremi_md.md)]. To take advantage of this in compatibility level 140 and higher, [Percentile memory grant feedback must be enabled](#enable-memory-grant-feedback-persistence-and-percentile).
213-
- Persistence for memory grant, CE, and DOP feedback is on by default in [!INCLUDE[ssSQL22](../../includes/sssql22-md.md)]. Persistence is not currently available in [!INCLUDE[ssSDSfull](../../includes/sssdsfull-md.md)] and [!INCLUDE[ssazuremi_md](../../includes/ssazuremi_md.md)].
213+
It's recommended that you have a performance baseline for your workload before the feature is enabled for your database. The baseline numbers will help you determine if you're getting the intended benefit from the feature.
214214

215215
Memory grant feedback (MGF) is an existing feature that adjusts the size of the memory allocated for a query based on past performance. However, the initial phases of this project only stored the memory grant adjustment with the plan in the cache – if a plan is evicted from the cache, the feedback process must start again, resulting in poor performance the first few times a query is executed after eviction. The new solution is to persist the grant information with the other query information in the Query Store so that the benefits last across cache evictions. Memory grant feedback persistence and percentile address existing limitations of memory grant feedback in a non-intrusive way.
216216

@@ -230,11 +230,11 @@ Persistence also applies to [DOP feedback](#degree-of-parallelism-dop-feedback)
230230

231231
#### Enable memory grant feedback: persistence and percentile
232232

233-
To enable memory grant feedback persistence and percentile, use database compatibility level 140 or higher for the database you're connected to when executing the query.
233+
To enable memory grant feedback persistence and percentile, use database compatibility level 140 or higher for the database you're connected to when executing the query. Peristence and percentile feedback are [enabled by default](#percentile-and-persistence-mode-memory-grant-feedback).
234234

235235
`ALTER DATABASE <DATABASE NAME> SET COMPATIBILITY LEVEL = 140; -- OR HIGHER`
236236

237-
The Query Store must be enabled for every database where the persistence portion of this feature is used.
237+
The Query Store must be enabled for every database where the persistence portion of this feature is used.
238238

239239
#### Disable percentile
240240

@@ -256,7 +256,7 @@ Disabling memory grant feedback persistence will also remove existing collected
256256

257257
The default setting for `MEMORY_GRANT_FEEDBACK_PERSISTENCE` is `ON`.
258258

259-
#### Considerations
259+
#### Considerations for memory grant feedback
260260

261261
You can view your current settings by querying `sys.database_scoped_configurations`.
262262

@@ -267,6 +267,8 @@ Given feedback data is now persisted in the Query Store, there's some increase i
267267

268268
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.
269269

270+
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).
271+
270272
## Degree of parallelism (DOP) feedback
271273

272274
**Applies to:** [!INCLUDE[sssql22-md](../../includes/sssql22-md.md)] and later
@@ -279,7 +281,7 @@ Parallelism is often beneficial for reporting and analytical queries, or queries
279281

280282
- To enable DOP feedback, enable the `DOP_FEEDBACK` [database scoped configuration](../../t-sql/statements/alter-database-scoped-configuration-transact-sql.md#dop_feedback---on--off-) in a database.
281283

282-
- The Query Store must be enabled for every database where DOP feedback is used, and in the "Read write" state. Feedback will be persisted in the `sys.query_store_plan_feedback` catalog view when we reach a stable degree of parallelism feedback value.
284+
- The Query Store must be enabled for every database where DOP feedback is used, and in the "Read write" state. Feedback will be persisted in the [sys.query_store_plan_feedback](../system-catalog-views/sys-query-store-plan-feedback.md) catalog view when we reach a stable degree of parallelism feedback value.
283285

284286
- DOP feedback is available for queries that operate in the database compatibility level 160 (introduced with [!INCLUDE [sssql22-md](../../includes/sssql22-md.md)]) or higher.
285287

@@ -290,8 +292,8 @@ Parallelism is often beneficial for reporting and analytical queries, or queries
290292
- To disable DOP feedback at the database level, use the `ALTER DATABASE SCOPED CONFIGURATION SET DOP_FEEDBACK = OFF` [database scoped configuration](../../t-sql/statements/alter-database-scoped-configuration-transact-sql.md#dop_feedback---on--off-).
291293

292294
- To disable DOP feedback at the query level, use the `DISABLE_DOP_FEEDBACK` query hint.
293-
294-
- 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. For more information, see [Query Store for secondary replicas](monitoring-performance-by-using-the-query-store.md#query-store-for-secondary-replicas).
295+
296+
- 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).
295297

296298
### DOP feedback implementation
297299

@@ -308,7 +310,7 @@ Only verified feedback is persisted. If the adjusted DOP results in a performanc
308310

309311
Minimum DOP for any query adjusted with DOP feedback is 2. Serial executions are out of scope for DOP feedback.
310312

311-
Feedback information can be tracked using the `sys.query_store_plan_feedback` catalog view.
313+
Feedback information can be tracked using the [sys.query_store_plan_feedback](../system-catalog-views/sys-query-store-plan-feedback.md) catalog view.
312314

313315
If a query has a query plan forced through Query Store, DOP feedback can still be used for that query.
314316

@@ -333,7 +335,7 @@ Starting with [!INCLUDE[sql-server-2022](../../includes/sssql22-md.md)]), the Ca
333335

334336
Because no single set of CE models and assumptions can accommodate the vast array of customer workloads and data distributions, CE feedback provides an adaptable solution based on query runtime characteristics. CE feedback will identify and use a model assumption that better fits a given query and data distribution to improve query execution plan quality. Feedback is applied when significant model estimation errors resulting in performance drops are found.
335337

336-
- Starting with [!INCLUDE [sssql22-md](../../includes/sssql22-md.md)], when Query Store for secondary replicas is enabled, CE feedback is also replica-aware for secondary replicas in availability groups. CE feedback can apply feedback differently on a primary replica and on a secondary replica. For more information, see [Query Store for secondary replicas](monitoring-performance-by-using-the-query-store.md#query-store-for-secondary-replicas).
338+
- Starting with [!INCLUDE [sssql22-md](../../includes/sssql22-md.md)], when Query Store for secondary replicas is enabled, CE feedback is not replica-aware for secondary replicas in availability groups. CE feedback currently only benefits primary replicas. For more information, see [Query Store for secondary replicas](query-store-for-secondary-replicas.md).
337339

338340
### Understand Cardinality Estimation
339341

@@ -433,7 +435,7 @@ CE feedback activity is visible via the `query_feedback_analysis` and `query_fee
433435

434436
Hints set by CE feedback can be tracked using the [sys.query_store_query_hints](../system-catalog-views/sys-query-store-query-hints-transact-sql.md) catalog view.
435437

436-
Feedback information can be tracked using the `sys.query_store_plan_feedback` catalog view.
438+
Feedback information can be tracked using the [sys.query_store_plan_feedback](../system-catalog-views/sys-query-store-plan-feedback.md) catalog view.
437439

438440
To disable CE feedback at the database level, use the `ALTER DATABASE SCOPED CONFIGURATION SET CE_FEEDBACK = OFF` [database scoped configuration](../../t-sql/statements/alter-database-scoped-configuration-transact-sql.md#ce_feedback---on--off-).
439441

0 commit comments

Comments
 (0)