Skip to content

Latest commit

 

History

History
126 lines (101 loc) · 17.1 KB

File metadata and controls

126 lines (101 loc) · 17.1 KB
title Intelligent query processing
description Intelligent query processing features to improve query performance in SQL Server, Azure SQL Managed Instance, and Azure SQL Database.
ms.prod sql
ms.prod_service database-engine, sql-database
ms.technology performance
ms.topic conceptual
helpviewer_keywords
author MikeRayMSFT
ms.author mikeray
ms.reviewer wiassaf
ms.custom
seo-dt-2019
event-tier1-build-2022
ms.date 10/12/2022
monikerRange =azuresqldb-current||>=sql-server-2016||>=sql-server-linux-2017||=azuresqldb-mi-current

Intelligent query processing in SQL databases

[!INCLUDE SQL Server Azure SQL Database Azure SQL Managed Instance]

The intelligent query processing (IQP) feature family includes features with broad impact that improve the performance of existing workloads with minimal implementation effort to adopt. The following graphic details the family of IQP features and when they were first introduced for SQL Server. All IQP features are available in [!INCLUDEssazuremi_md] and [!INCLUDEssSDSfull]. Some features depend on the database's compatibility level.

:::image type="content" source="./media/iqp-feature-family.svg" alt-text="A diagram of the Intelligent Query Processing family of features and when they were first introduced to SQL Server.":::

Watch this 6-minute video for an overview of intelligent query processing:

[!VIDEO https://channel9.msdn.com/Shows/Data-Exposed/Overview-Intelligent-Query-processing-in-SQL-Server-2019/player?WT.mc_id=dataexposed-c9-niner]

For demos and sample code of intelligent query processing (IQP) features on GitHub, visit https://aka.ms/IQPDemos.

You can make workloads automatically eligible for intelligent query processing by enabling the applicable database compatibility level for the database. You can set this using [!INCLUDEtsql]. For example:

ALTER DATABASE [WideWorldImportersDW] SET COMPATIBILITY_LEVEL = 150;

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.

IQP features for [!INCLUDEssSDSfull], [!INCLUDEssSDSMIfull], [!INCLUDEsssql22-md]

IQP Feature Supported in [!INCLUDEssSDSfull] and [!INCLUDEssSDSMIfull] Supported in [!INCLUDEsssql22-md] Description
Adaptive Joins (Batch Mode) Yes, starting with database compatibility level 140 Yes, starting in [!INCLUDEssSQL17] with database compatibility level 140 Adaptive joins dynamically select a join type during runtime based on actual input rows.
Approximate Count Distinct Yes Yes, starting in [!INCLUDEsql-server-2019] Provide approximate COUNT DISTINCT for big data scenarios with the benefit of high performance and a low memory footprint.
Approximate Percentile Yes, starting with database compatibility level 110 Yes, starting in [!INCLUDEsql-server-2022] with 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.
Batch Mode on Rowstore Yes, starting with database compatibility level 150 Yes, starting in [!INCLUDEsql-server-2019] with compatibility level 150 Provide batch mode for CPU-bound relational DW workloads without requiring columnstore indexes.
Cardinality estimation (CE) feedback Yes, in Preview, starting with database compatibility level 160 Yes, starting in [!INCLUDEsql-server-2022] with 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.
Degrees of Parallelism (DOP) feedback No Yes, starting in [!INCLUDEsql-server-2022] with 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.
Interleaved Execution Yes, starting with database compatibility level 140 Yes, starting in [!INCLUDEssSQL17] 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.
Memory grant feedback (Batch Mode) Yes, starting with database compatibility level 140 Yes, starting in [!INCLUDEssSQL17] 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.
Memory grant feedback (Row Mode) Yes, starting with database compatibility level 150 Yes, starting in [!INCLUDEsql-server-2019] 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.
Memory grant feedback (Percentile) No Yes, starting with [!INCLUDEsql-server-2022]) 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.
Memory Grant, CE, and DOP feedback persistence No Yes, starting with [!INCLUDEsql-server-2022]) 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.
Optimized plan forcing No Yes, starting with [!INCLUDEsql-server-2022]). Reduces compilation overhead for repeating forced queries. For more information, see Optimized plan forcing with Query Store.
Scalar UDF Inlining Yes, starting with database compatibility level 150 Yes, starting in [!INCLUDEsql-server-2019] 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.
Parameter Sensitivity Plan Optimization No Yes, (Starting in [!INCLUDEsql-server-2022]) 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.
Table Variable Deferred Compilation Yes, starting with database compatibility level 150 Yes, starting in [!INCLUDEsql-server-2019] with database compatibility level 150 Uses the actual cardinality of the table variable encountered on first compilation instead of a fixed guess.

IQP features for [!INCLUDEsssql19-md]

IQP Feature Supported in [!INCLUDEsssql19-md] Description
Adaptive Joins (Batch Mode) Yes, starting in [!INCLUDEssSQL17] with database compatibility level 140 Adaptive joins dynamically select a join type during runtime based on actual input rows.
Approximate Count Distinct Yes Provide approximate COUNT DISTINCT for big data scenarios with the benefit of high performance and a low memory footprint.
Batch Mode on Rowstore Yes, starting with database compatibility level 150 Provide batch mode for CPU-bound relational DW workloads without requiring columnstore indexes.
Interleaved Execution Yes, starting with database compatibility level 140 Use the actual cardinality of the multi-statement table valued function encountered on first compilation instead of a fixed guess.
Memory grant feedback (Batch Mode) 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.
Memory grant feedback (Row Mode) 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.
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.
Table Variable Deferred Compilation Yes, starting with database compatibility level 150 Use the actual cardinality of the table variable encountered on first compilation instead of a fixed guess.

IQP features for [!INCLUDEsssql17-md]

IQP Feature Supported in [!INCLUDEsssql17-md] Description
Adaptive Joins (Batch Mode) Yes, starting in [!INCLUDEssSQL17] with database compatibility level 140 Adaptive joins dynamically select a join type during runtime based on actual input rows.
Approximate Count Distinct Yes Provide approximate COUNT DISTINCT for big data scenarios with the benefit of high performance and a low memory footprint.
Interleaved Execution Yes, starting with database compatibility level 140 Use the actual cardinality of the multi-statement table valued function encountered on first compilation instead of a fixed guess.
Memory grant feedback (Batch Mode) 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.

Query Store requirement

Several of the suite of intelligent query processing features require the Query Store to be enabled in order to benefit the user database. To enable the Query Store, see Enable the Query Store.

IQP Feature Requires Query Store to be enabled and READ_WRITE
Adaptive Joins (Batch Mode) No
Approximate Count Distinct No
Approximate Percentile No
Batch Mode on Rowstore No
Cardinality estimation (CE) feedback Yes
Degrees of Parallelism (DOP) feedback Yes
Interleaved Execution No
Memory grant feedback (Batch Mode) Partially
Memory grant feedback (Row Mode) Partially
Memory grant feedback (Percentile) Yes
Memory Grant, CE, and DOP feedback persistence No
Optimized plan forcing Yes
Scalar UDF Inlining No
Parameter Sensitivity Plan Optimization No, but recommended
Table Variable Deferred Compilation No

See also

For complete details on all IQP features, including release notes and more in-depth descriptions, see Intelligent query processing (IQP) feature details.

Next steps