Skip to content

Commit da2aacb

Browse files
20230608 MGF for SQL DB
1 parent 01bdd20 commit da2aacb

2 files changed

Lines changed: 39 additions & 15 deletions

File tree

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

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Learn about query processing feedback features, part of the Intelli
44
author: WilliamDAssafMSFT
55
ms.author: wiassaf
66
ms.reviewer: katsmith
7-
ms.date: 05/02/2023
7+
ms.date: 06/08/2023
88
ms.service: sql
99
ms.subservice: configuration
1010
ms.topic: conceptual
@@ -173,6 +173,7 @@ Values surfaced in this attribute are as follows:
173173
| No: Accurate Grant | If there's no spill to disk and the statement uses at least 50% of the granted memory, then memory grant feedback isn't triggered. |
174174
| No: Feedback disabled | If memory grant feedback is continually triggered and fluctuates between memory-increase and memory-decrease operations, the database engine will disable memory grant feedback for the statement. |
175175
| Yes: Adjusting | Memory grant feedback has been applied and may be further adjusted for the next execution. |
176+
| Yes: Percentile Adjusting | Memory grant feedback is being applied using the percentile grant algorithm, which looks at more history than only the most recent execution. |
176177
| Yes: Stable | Memory grant feedback has been applied and granted memory is now stable, meaning that what was last granted for the previous execution is what was granted for the current execution. |
177178

178179
#### Disable row mode memory grant feedback without changing the compatibility level
@@ -201,14 +202,14 @@ A USE HINT query hint takes precedence over a [database scoped configuration](..
201202

202203
### Percentile and persistence mode memory grant feedback
203204

204-
**Applies to:** [!INCLUDE[sssql22-md](../../includes/sssql22-md.md)] and later
205+
**Applies to:** [!INCLUDE[ssSDSfull](../../includes/sssdsfull-md.md)], [!INCLUDE[sssql22-md](../../includes/sssql22-md.md)] and later
205206

206-
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.
207+
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.
207208

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)].
209+
- Percentile memory grant feedback is enabled by default in [!INCLUDE[ssSQL22](../../includes/sssql22-md.md)], but has no effect if Query Store is not enabled or when Query Store is not in a "read write" state.
210+
- Persistence for memory grant, CE, and DOP feedback is on by default in [!INCLUDE[ssSQL22](../../includes/sssql22-md.md)], but has no effect when Query Store is not enabled or when Query Store is not in a "read write" state.
211+
- Percentile and persistence for memory grant feedback is available in [!INCLUDE[ssSDSfull](../../includes/sssdsfull-md.md)], and enabled by default on all databases, both existing and new.
212+
- Percentile and persistence for memory grant feedback is not currently available in [!INCLUDE[ssazuremi_md](../../includes/ssazuremi_md.md)].
212213

213214
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.
214215

@@ -230,19 +231,21 @@ Persistence also applies to [DOP feedback](#degree-of-parallelism-dop-feedback)
230231

231232
#### Enable memory grant feedback: persistence and percentile
232233

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. Persistence and percentile feedback are [enabled by default](#percentile-and-persistence-mode-memory-grant-feedback).
234+
Persistence and percentile feedback are [enabled by default](#percentile-and-persistence-mode-memory-grant-feedback) in [!INCLUDE[ssSDSfull](../../includes/sssdsfull-md.md)] and [!INCLUDE[ssSQL22](../../includes/sssql22-md.md)].
235+
236+
Use database compatibility level 140 or higher for the database you're connected to when executing the query. You can change this via [ALTER DATABASE](../../t-sql/statements/alter-database-transact-sql-compatibility-level.md):
234237

235238
`ALTER DATABASE <DATABASE NAME> SET COMPATIBILITY LEVEL = 140; -- OR HIGHER`
236239

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

239242
#### Disable percentile
240243

241244
To disable memory grant feedback percentile for all query executions originating from the database, execute the following within the context of the applicable database:
242245

243246
`ALTER DATABASE SCOPED CONFIGURATION SET MEMORY_GRANT_FEEDBACK_PERCENTILE = OFF;`
244247

245-
The default setting for `MEMORY_GRANT_FEEDBACK_PERCENTILE` is `OFF`.
248+
The default setting for `MEMORY_GRANT_FEEDBACK_PERCENTILE` is `ON`.
246249

247250
#### Disable persistence
248251

@@ -258,7 +261,7 @@ The default setting for `MEMORY_GRANT_FEEDBACK_PERSISTENCE` is `ON`.
258261

259262
#### Considerations for memory grant feedback
260263

261-
You can view your current settings by querying `sys.database_scoped_configurations`.
264+
You can view your current settings by querying [sys.database_scoped_configurations](../system-catalog-views/sys-database-scoped-configurations-transact-sql.md).
262265

263266
> [!NOTE]
264267
> That this feature won't work if both `BATCH_MODE_MEMORY_GRANT_FEEDBACK` and `ROW_MODE_MEMORY_GRANT_FEEDBACK` are set to OFF.

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

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: "Intelligent query processing features to improve query performance
44
author: "MikeRayMSFT"
55
ms.author: "mikeray"
66
ms.reviewer: "wiassaf"
7-
ms.date: 10/12/2022
7+
ms.date: 06/08/2023
88
ms.service: sql
99
ms.subservice: performance
1010
ms.topic: conceptual
@@ -33,9 +33,9 @@ ALTER DATABASE [WideWorldImportersDW] SET COMPATIBILITY_LEVEL = 150;
3333

3434
The following table details all intelligent query processing features, along with any requirement they have for database compatibility level. For complete details on all IQP features, including release notes and more in-depth descriptions, see [Intelligent query processing (IQP) feature details](intelligent-query-processing-details.md).
3535

36-
## <a id="sql2022"></a> IQP features for [!INCLUDE[ssSDSfull](../../includes/sssdsfull-md.md)], [!INCLUDE[ssSDSMIfull](../../includes/sssdsmifull-md.md)], [!INCLUDE[sssql22-md](../../includes/sssql22-md.md)]
36+
## <a id="sql2022"></a> IQP features for [!INCLUDE[ssSDSfull](../../includes/sssdsfull-md.md)] and [!INCLUDE[sssql22-md](../../includes/sssql22-md.md)]
3737

38-
| **IQP Feature** | **Supported in [!INCLUDE[ssSDSfull](../../includes/sssdsfull-md.md)] and [!INCLUDE[ssSDSMIfull](../../includes/sssdsmifull-md.md)]** | **Supported in [!INCLUDE[sssql22-md](../../includes/sssql22-md.md)]** |**Description** |
38+
| **IQP Feature** | **Supported in [!INCLUDE[ssSDSfull](../../includes/sssdsfull-md.md)] | **Supported in [!INCLUDE[sssql22-md](../../includes/sssql22-md.md)]** |**Description** |
3939
| ---------------- | ------- | ------- | ---------------- |
4040
| [Adaptive Joins (Batch Mode)](intelligent-query-processing-details.md#batch-mode-adaptive-joins) | Yes, starting with database compatibility level 140| Yes, starting in [!INCLUDE[ssSQL17](../../includes/sssql17-md.md)] with database compatibility level 140|Adaptive joins dynamically select a join type during runtime based on actual input rows.|
4141
| [Approximate Count Distinct](intelligent-query-processing-details.md#approximate-query-processing) | Yes| Yes, starting in [!INCLUDE[sql-server-2019](../../includes/sssql19-md.md)]|Provide approximate COUNT DISTINCT for big data scenarios with the benefit of high performance and a low memory footprint. |
@@ -47,14 +47,35 @@ The following table details all intelligent query processing features, along wit
4747
| [Memory grant feedback (Batch Mode)](intelligent-query-processing-feedback.md#batch-mode-memory-grant-feedback) | Yes, starting with database compatibility level 140| Yes, starting in [!INCLUDE[ssSQL17](../../includes/sssql17-md.md)] with database compatibility level 140|If a batch mode query has operations that spill to disk, add more memory for consecutive executions. If a query wastes > 50% of the memory allocated to it, reduce the memory grant size for consecutive executions.|
4848
| [Memory grant feedback (Row Mode)](intelligent-query-processing-feedback.md#row-mode-memory-grant-feedback) | Yes, starting with database compatibility level 150| Yes, starting in [!INCLUDE[sql-server-2019](../../includes/sssql19-md.md)] with database compatibility level 150|If a row mode query has operations that spill to disk, add more memory for consecutive executions. If a query wastes > 50% of the memory allocated to it, reduce the memory grant size for consecutive executions.|
4949
| [Memory grant feedback (Percentile)](intelligent-query-processing-feedback.md#percentile-and-persistence-mode-memory-grant-feedback) | No <!--Yes, starting with database compatibility level 160--> | Yes, starting with [!INCLUDE[sql-server-2022](../../includes/sssql22-md.md)]) with database compatibility level 140 | Addresses existing limitations of memory grant feedback in a non-intrusive way by incorporating past query execution to refine feedback. |
50-
| [Memory Grant, CE, and DOP feedback persistence](intelligent-query-processing-feedback.md#percentile-and-persistence-mode-memory-grant-feedback) | No <!--Yes, starting with database compatibility level 160--> | Yes, starting with [!INCLUDE[sql-server-2022](../../includes/sssql22-md.md)]) with database compatibility level 140 | Provides new functionality to persist memory grant feedback. CE and DOP feedback is always persisted. Requires Query Store to be enabled for the database and in READ_WRITE mode. |
50+
| [Memory Grant feedback persistence](intelligent-query-processing-feedback.md#percentile-and-persistence-mode-memory-grant-feedback) | Yes, enabled on all databases | Yes, starting with [!INCLUDE[sql-server-2022](../../includes/sssql22-md.md)]) with database compatibility level 140 | Provides new functionality to persist memory grant feedback. Requires Query Store to be enabled for the database and in READ_WRITE mode. |
51+
| [CE and DOP feedback persistence](intelligent-query-processing-feedback.md#percentile-and-persistence-mode-memory-grant-feedback) | No <!--Yes, starting with database compatibility level 160--> | Yes, starting with [!INCLUDE[sql-server-2022](../../includes/sssql22-md.md)]) with database compatibility level 140 | Requires Query Store to be enabled for the database and in READ_WRITE mode. |
5152
| [Optimized plan forcing](optimized-plan-forcing-query-store.md) | No <!--Yes, starting with database compatibility level 160--> | Yes, starting with [!INCLUDE[sql-server-2022](../../includes/sssql22-md.md)]). | Reduces compilation overhead for repeating forced queries. For more information, see [Optimized plan forcing with Query Store](optimized-plan-forcing-query-store.md). |
5253
| [Scalar UDF Inlining](intelligent-query-processing-details.md#scalar-udf-inlining) | Yes, starting with database compatibility level 150 | Yes, starting in [!INCLUDE[sql-server-2019](../../includes/sssql19-md.md)] with database compatibility level 150|Scalar UDFs are transformed into equivalent relational expressions that are "inlined" into the calling query, often resulting in significant performance gains.|
5354
| [Parameter Sensitivity Plan Optimization](./parameter-sensitive-plan-optimization.md) | No <!--Yes, starting with database compatibility level 160-->| Yes, (Starting in [!INCLUDE[sql-server-2022](../../includes/sssql22-md.md)]) with database compatibility level 160 | Parameter Sensitivity Plan Optimization addresses the scenario where a single cached plan for a parameterized query is not optimal for all possible incoming parameter values, for example non-uniform data distributions. |
5455
| [Table Variable Deferred Compilation](intelligent-query-processing-details.md#table-variable-deferred-compilation) | Yes, starting with database compatibility level 150 | Yes, starting in [!INCLUDE[sql-server-2019](../../includes/sssql19-md.md)] with database compatibility level 150 | Uses the actual cardinality of the table variable encountered on first compilation instead of a fixed guess.|
5556

5657
* [DOP Feedback](intelligent-query-processing-feedback.md#degree-of-parallelism-dop-feedback) is currently available in [!INCLUDE[ssSDSfull](../../includes/sssdsfull-md.md)] as a limited preview. For more information and how to apply for the preview, see [Announcing Degree of Parallelism Feedback Limited Preview](https://techcommunity.microsoft.com/t5/azure-sql-blog/announcing-degree-of-parallelism-feedback-limited-preview/ba-p/3806924).
5758

59+
## <a id="sqlmi"></a> IQP features for [!INCLUDE[ssSDSMIfull](../../includes/sssdsmifull-md.md)]
60+
61+
| **IQP Feature** | **Supported in [!INCLUDE[ssSDSMIfull](../../includes/sssdsmifull-md.md)]** | **Description** |
62+
| ---------------- | ------- | ------- | ---------------- |
63+
| [Adaptive Joins (Batch Mode)](intelligent-query-processing-details.md#batch-mode-adaptive-joins) | Yes, starting with database compatibility level 140 | Adaptive joins dynamically select a join type during runtime based on actual input rows.|
64+
| [Approximate Count Distinct](intelligent-query-processing-details.md#approximate-query-processing) | Yes| Provide approximate COUNT DISTINCT for big data scenarios with the benefit of high performance and a low memory footprint. |
65+
| [Approximate Percentile](intelligent-query-processing-details.md#approximate-query-processing) | Yes, starting with database compatibility level 110 | Quickly compute percentiles for a large dataset with acceptable rank-based error bounds to help make rapid decisions by using approximate percentile aggregate functions.|
66+
| [Batch Mode on Rowstore](intelligent-query-processing-details.md#batch-mode-on-rowstore) | Yes, starting with database compatibility level 150| Yes, starting in [!INCLUDE[sql-server-2019](../../includes/sssql19-md.md)] with compatibility level 150|Provide batch mode for CPU-bound relational DW workloads without requiring columnstore indexes. |
67+
| [Cardinality estimation (CE) feedback](intelligent-query-processing-feedback.md#cardinality-estimation-ce-feedback) | No <!--Yes, in Preview, starting with database compatibility level 160 --> | Automatically adjusts cardinality estimates for repeating queries to optimize workloads where inefficient CE assumptions cause poor query performance. CE feedback will identify and use a model assumption that better fits a given query and data distribution to improve query execution plan quality. |
68+
| [Degrees of Parallelism (DOP) feedback](intelligent-query-processing-feedback.md#degree-of-parallelism-dop-feedback) | Yes, starting with database compatibility level 160. | Automatically adjusts degree of parallelism for repeating queries to optimize for workloads where inefficient parallelism can cause performance issues. Requires Query Store to be enabled.|
69+
| [Interleaved Execution](intelligent-query-processing-details.md#interleaved-execution-for-mstvfs) | Yes, starting with database compatibility level 140 | Uses the actual cardinality of the multi-statement table valued function encountered on first compilation instead of a fixed guess.|
70+
| [Memory grant feedback (Batch Mode)](intelligent-query-processing-feedback.md#batch-mode-memory-grant-feedback) | Yes, starting with database compatibility level 140 | If a batch mode query has operations that spill to disk, add more memory for consecutive executions. If a query wastes > 50% of the memory allocated to it, reduce the memory grant size for consecutive executions.|
71+
| [Memory grant feedback (Row Mode)](intelligent-query-processing-feedback.md#row-mode-memory-grant-feedback) | Yes, starting with database compatibility level 150 | If a row mode query has operations that spill to disk, add more memory for consecutive executions. If a query wastes > 50% of the memory allocated to it, reduce the memory grant size for consecutive executions.|
72+
| [Memory grant feedback (Percentile)](intelligent-query-processing-feedback.md#percentile-and-persistence-mode-memory-grant-feedback) | No <!--Yes, starting with database compatibility level 160--> | Addresses existing limitations of memory grant feedback in a non-intrusive way by incorporating past query execution to refine feedback. |
73+
| [Memory Grant, CE, and DOP feedback persistence](intelligent-query-processing-feedback.md#percentile-and-persistence-mode-memory-grant-feedback) | No <!--Yes, starting with database compatibility level 160--> | Provides new functionality to persist memory grant feedback. CE and DOP feedback is always persisted. Requires Query Store to be enabled for the database and in READ_WRITE mode. |
74+
| [Optimized plan forcing](optimized-plan-forcing-query-store.md) | No <!--Yes, starting with database compatibility level 160--> | Reduces compilation overhead for repeating forced queries. For more information, see [Optimized plan forcing with Query Store](optimized-plan-forcing-query-store.md). |
75+
| [Scalar UDF Inlining](intelligent-query-processing-details.md#scalar-udf-inlining) | Yes, starting with database compatibility level 150 | Scalar UDFs are transformed into equivalent relational expressions that are "inlined" into the calling query, often resulting in significant performance gains.|
76+
| [Parameter Sensitivity Plan Optimization](./parameter-sensitive-plan-optimization.md) | No <!--Yes, starting with database compatibility level 160-->| Parameter Sensitivity Plan Optimization addresses the scenario where a single cached plan for a parameterized query is not optimal for all possible incoming parameter values, for example non-uniform data distributions. |
77+
| [Table Variable Deferred Compilation](intelligent-query-processing-details.md#table-variable-deferred-compilation) | Yes, starting with database compatibility level 150 | Uses the actual cardinality of the table variable encountered on first compilation instead of a fixed guess.|
78+
5879
## <a id="sql2019"></a> IQP features for [!INCLUDE[sssql19-md](../../includes/sssql19-md.md)]
5980

6081
| **IQP Feature** | **Supported in [!INCLUDE[sssql19-md](../../includes/sssql19-md.md)]** |**Description** |

0 commit comments

Comments
 (0)