Skip to content

Commit 6badba4

Browse files
authored
Merge pull request #192121 from LitKnd/link-to-new-missing-index-article
Adding links to new missing index article in the sqldocs repo
2 parents d6ecbaf + 0a500f3 commit 6badba4

File tree

2 files changed

+27
-21
lines changed

2 files changed

+27
-21
lines changed

articles/azure-sql/database/performance-guidance.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ms.topic: conceptual
1111
author: WilliamDAssafMSFT
1212
ms.author: wiassaf
1313
ms.reviewer: kendralittle, mathoma
14-
ms.date: 07/26/2021
14+
ms.date: 03/18/2022
1515
---
1616
# Tune applications and databases for performance in Azure SQL Database and Azure SQL Managed Instance
1717
[!INCLUDE[appliesto-sqldb-sqlmi](../includes/appliesto-sqldb-sqlmi.md)]
@@ -39,11 +39,11 @@ Although Azure SQL Database and Azure SQL Managed Instance service tiers are des
3939

4040
Databases that exceed the resources of the highest Premium compute size might benefit from scaling out the workload. For more information, see [Cross-database sharding](#cross-database-sharding) and [Functional partitioning](#functional-partitioning).
4141

42-
- **Applications that have sub-optimal queries**
42+
- **Applications that have suboptimal queries**
4343

4444
Applications, especially those in the data access layer, that have poorly tuned queries might not benefit from a higher compute size. This includes queries that lack a WHERE clause, have missing indexes, or have outdated statistics. These applications benefit from standard query performance-tuning techniques. For more information, see [Missing indexes](#identifying-and-adding-missing-indexes) and [Query tuning and hinting](#query-tuning-and-hinting).
4545

46-
- **Applications that have sub-optimal data access design**
46+
- **Applications that have suboptimal data access design**
4747

4848
Applications that have inherent data access concurrency issues, for example deadlocking, might not benefit from a higher compute size. Consider reducing round trips against the database by caching data on the client side with the Azure Caching service or another caching technology. See [Application tier caching](#application-tier-caching).
4949

@@ -116,15 +116,17 @@ After it's created, that same SELECT statement picks a different plan, which use
116116

117117
![A query plan with corrected indexes](./media/performance-guidance/query_plan_corrected_indexes.png)
118118

119-
The key insight is that the IO capacity of a shared, commodity system is more limited than that of a dedicated server machine. There's a premium on minimizing unnecessary IO to take maximum advantage of the system in the resources of each compute size of the service tiers. Appropriate physical database design choices can significantly improve the latency for individual queries, improve the throughput of concurrent requests handled per scale unit, and minimize the costs required to satisfy the query. For more information about the missing index DMVs, see [sys.dm_db_missing_index_details](/sql/relational-databases/system-dynamic-management-views/sys-dm-db-missing-index-details-transact-sql).
119+
The key insight is that the IO capacity of a shared, commodity system is more limited than that of a dedicated server machine. There's a premium on minimizing unnecessary IO to take maximum advantage of the system in the resources of each compute size of the service tiers. Appropriate physical database design choices can significantly improve the latency for individual queries, improve the throughput of concurrent requests handled per scale unit, and minimize the costs required to satisfy the query.
120+
121+
For more information about tuning indexes using missing index requests, see [Tune nonclustered indexes with missing index suggestions](/sql/relational-databases/indexes/tune-nonclustered-missing-index-suggestions).
120122

121123
### Query tuning and hinting
122124

123125
The query optimizer in Azure SQL Database and Azure SQL Managed Instance is similar to the traditional SQL Server query optimizer. Most of the best practices for tuning queries and understanding the reasoning model limitations for the query optimizer also apply to Azure SQL Database and Azure SQL Managed Instance. If you tune queries in Azure SQL Database and Azure SQL Managed Instance, you might get the additional benefit of reducing aggregate resource demands. Your application might be able to run at a lower cost than an un-tuned equivalent because it can run at a lower compute size.
124126

125-
An example that is common in SQL Server and which also applies to Azure SQL Database and Azure SQL Managed Instance is how the query optimizer "sniffs" parameters. During compilation, the query optimizer evaluates the current value of a parameter to determine whether it can generate a more optimal query plan. Although this strategy often can lead to a query plan that is significantly faster than a plan compiled without known parameter values, currently it works imperfectly both in SQL Server, in Azure SQL Database, and Azure SQL Managed Instance. Sometimes the parameter is not sniffed, and sometimes the parameter is sniffed but the generated plan is sub-optimal for the full set of parameter values in a workload. Microsoft includes query hints (directives) so that you can specify intent more deliberately and override the default behavior of parameter sniffing. Often, if you use hints, you can fix cases in which the default SQL Server, Azure SQL Database, and Azure SQL Managed Instance behavior is imperfect for a specific customer workload.
127+
An example that is common in SQL Server and which also applies to Azure SQL Database and Azure SQL Managed Instance is how the query optimizer "sniffs" parameters. During compilation, the query optimizer evaluates the current value of a parameter to determine whether it can generate a more optimal query plan. Although this strategy often can lead to a query plan that is significantly faster than a plan compiled without known parameter values, currently it works imperfectly both in SQL Server, in Azure SQL Database, and Azure SQL Managed Instance. Sometimes the parameter is not sniffed, and sometimes the parameter is sniffed but the generated plan is suboptimal for the full set of parameter values in a workload. Microsoft includes query hints (directives) so that you can specify intent more deliberately and override the default behavior of parameter sniffing. Often, if you use hints, you can fix cases in which the default SQL Server, Azure SQL Database, and Azure SQL Managed Instance behavior is imperfect for a specific customer workload.
126128

127-
The next example demonstrates how the query processor can generate a plan that is sub-optimal both for performance and resource requirements. This example also shows that if you use a query hint, you can reduce query run time and resource requirements for your database:
129+
The next example demonstrates how the query processor can generate a plan that is suboptimal both for performance and resource requirements. This example also shows that if you use a query hint, you can reduce query run time and resource requirements for your database:
128130

129131
```sql
130132
DROP TABLE psptest1;
@@ -164,7 +166,7 @@ CREATE TABLE t1 (col1 int primary key, col2 int, col3 binary(200));
164166
GO
165167
```
166168

167-
The setup code creates a table that has skewed data distribution. The optimal query plan differs based on which parameter is selected. Unfortunately, the plan caching behavior doesn't always recompile the query based on the most common parameter value. So, it's possible for a sub-optimal plan to be cached and used for many values, even when a different plan might be a better plan choice on average. Then the query plan creates two stored procedures that are identical, except that one has a special query hint.
169+
The setup code creates a table that has skewed data distribution. The optimal query plan differs based on which parameter is selected. Unfortunately, the plan caching behavior doesn't always recompile the query based on the most common parameter value. So, it's possible for a suboptimal plan to be cached and used for many values, even when a different plan might be a better plan choice on average. Then the query plan creates two stored procedures that are identical, except that one has a special query hint.
168170

169171
```sql
170172
-- Prime Procedure Cache with scan plan
@@ -200,7 +202,7 @@ Each part of this example attempts to run a parameterized insert statement 1,000
200202

201203
![Query tuning by using a scan plan](./media/performance-guidance/query_tuning_1.png)
202204

203-
Because we executed the procedure by using the value 1, the resulting plan was optimal for the value 1 but was sub-optimal for all other values in the table. The result likely isn't what you would want if you were to pick each plan randomly, because the plan performs more slowly and uses more resources.
205+
Because we executed the procedure by using the value 1, the resulting plan was optimal for the value 1 but was suboptimal for all other values in the table. The result likely isn't what you would want if you were to pick each plan randomly, because the plan performs more slowly and uses more resources.
204206

205207
If you run the test with `SET STATISTICS IO` set to `ON`, the logical scan work in this example is done behind the scenes. You can see that there are 1,148 reads done by the plan (which is inefficient, if the average case is to return just one row):
206208

@@ -222,7 +224,7 @@ ORDER BY start_time DESC
222224
![Query tuning example results](./media/performance-guidance/query_tuning_4.png)
223225

224226
> [!NOTE]
225-
> Although the volume in this example is intentionally small, the effect of sub-optimal parameters can be substantial, especially on larger databases. The difference, in extreme cases, can be between seconds for fast cases and hours for slow cases.
227+
> Although the volume in this example is intentionally small, the effect of suboptimal parameters can be substantial, especially on larger databases. The difference, in extreme cases, can be between seconds for fast cases and hours for slow cases.
226228
227229
You can examine **sys.resource_stats** to determine whether the resource for a test uses more or fewer resources than another test. When you compare data, separate the timing of tests so that they are not in the same 5-minute window in the **sys.resource_stats** view. The goal of the exercise is to minimize the total amount of resources used, and not to minimize the peak resources. Generally, optimizing a piece of code for latency also reduces resource consumption. Make sure that the changes you make to an application are necessary, and that the changes don't negatively affect the customer experience for someone who might be using query hints in the application.
228230

@@ -272,4 +274,5 @@ To learn more about the script and get started, visit the [wiki](https://aka.ms/
272274
- Read [What is an Azure elastic pool?](elastic-pool-overview.md)
273275
- Discover [When to consider an elastic pool](elastic-pool-overview.md)
274276
- Read about [Monitoring Microsoft Azure SQL Database and Azure SQL Managed Instance performance using dynamic management views](monitoring-with-dmvs.md)
275-
- Learn to [Diagnose and troubleshoot high CPU on Azure SQL Database](high-cpu-diagnose-troubleshoot.md)
277+
- Learn to [Diagnose and troubleshoot high CPU on Azure SQL Database](high-cpu-diagnose-troubleshoot.md)
278+
- [Tune nonclustered indexes with missing index suggestions](/sql/relational-databases/indexes/tune-nonclustered-missing-index-suggestions)

articles/azure-sql/identify-query-performance-issues.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
2-
title: Types of query performance issues in Azure SQL Database
3-
description: In this article, learn about types of query performance issues in Azure SQL Database and also learn how to identify and resolve queries with these issues
2+
title: Types of query performance issues
3+
titleSuffix: Azure SQL Database & Azure SQL Managed Instance
4+
description: Learn about types of query performance issues in Azure SQL Database and Azure SQL Managed Instance, and how to identify and resolve queries with these issues.
45
services: sql-database
56
ms.service: sql-database
67
ms.subservice: performance
@@ -10,15 +11,15 @@ ms.topic: troubleshooting
1011
author: NikaKinska
1112
ms.author: nnikolic
1213
ms.reviewer: mathoma, wiassaf, kendralittle
13-
ms.date: 11/04/2021
14+
ms.date: 03/18/2022
1415
---
1516

16-
# Detectable types of query performance bottlenecks in Azure SQL Database
17+
# Detectable types of query performance bottlenecks in Azure SQL Database and Azure SQL Managed Instance
1718
[!INCLUDE[appliesto-sqldb-sqlmi](includes/appliesto-sqldb-sqlmi.md)]
1819

1920
When trying to resolve a performance bottleneck, start by determining whether the bottleneck is occurring while the query is in a running state or a waiting state. Different resolutions apply depending upon this determination. Use the following diagram to help understand the factors that can cause either a running-related problem or a waiting-related problem. Problems and resolutions relating to each type of problem are discussed in this article.
2021

21-
You can use Azure SQL Database [Intelligent Insights](database/intelligent-insights-troubleshoot-performance.md#detectable-database-performance-patterns) or SQL Server [DMVs](database/monitoring-with-dmvs.md) to detect these types of performance bottlenecks.
22+
You can use [Intelligent Insights](database/intelligent-insights-troubleshoot-performance.md#detectable-database-performance-patterns) or SQL Server [DMVs](database/monitoring-with-dmvs.md) to detect these types of performance bottlenecks.
2223

2324
![Workload states](./media/identify-query-performance-issues/workload-states.png)
2425

@@ -27,7 +28,7 @@ You can use Azure SQL Database [Intelligent Insights](database/intelligent-insig
2728

2829
- Locks (blocking)
2930
- I/O
30-
- Contention related to TempDB usage
31+
- Contention related to tempdb usage
3132
- Memory grant waits
3233

3334
## Compilation problems resulting in a suboptimal query plan
@@ -37,9 +38,10 @@ A suboptimal plan generated by the SQL Query Optimizer may be the cause of slow
3738
- Identify any missing indexes using one of these methods:
3839

3940
- Use [Intelligent Insights](database/intelligent-insights-troubleshoot-performance.md#missing-index).
40-
- [Database Advisor](database/database-advisor-implement-performance-recommendations.md) for single and pooled databases.
41-
- DMVs. This example shows you the impact of a missing index, how to detect a [missing indexes](database/performance-guidance.md#identifying-and-adding-missing-indexes) using DMVs, and the impact of implementing the missing index recommendation.
42-
- Try to apply [query hints](/sql/t-sql/queries/hints-transact-sql-query), [update statistics](/sql/t-sql/statements/update-statistics-transact-sql), or [rebuild indexes](/sql/relational-databases/indexes/reorganize-and-rebuild-indexes) to get the better plan. Enable [automatic plan correction](../azure-sql/database/automatic-tuning-overview.md) in Azure SQL Database to automatically mitigate these problems.
41+
- Review recommendations in the [Database Advisor](database/database-advisor-implement-performance-recommendations.md) for single and pooled databases in Azure SQL Database. You may also choose to enable [automatic tuning options for tuning indexes](database/automatic-tuning-overview.md#automatic-tuning-options) for Azure SQL Database.
42+
- Missing indexes in DMVs and query execution plans. This article shows you how to [detect and tune nonclustered indexes using missing index requests](/sql/relational-databases/indexes/tune-nonclustered-missing-index-suggestions).
43+
- Try to [update statistics](/sql/t-sql/statements/update-statistics-transact-sql) or [rebuild indexes](/sql/relational-databases/indexes/reorganize-and-rebuild-indexes) to get the better plan. Enable [automatic plan correction](../azure-sql/database/automatic-tuning-overview.md) in Azure SQL Database or Azure SQL Managed Instance to automatically mitigate these problems.
44+
- As an advanced troubleshooting step, use [Query Store hints](/sql/relational-databases/performance/query-store-hints) to apply [query hints](/sql/t-sql/queries/hints-transact-sql-query) using the Query Store, without making code changes.
4345

4446
This [example](database/performance-guidance.md#query-tuning-and-hinting) shows the impact of a suboptimal query plan due to a parameterized query, how to detect this condition, and how to use a query hint to resolve.
4547

@@ -187,9 +189,9 @@ Once you have eliminated a suboptimal plan and *Waiting-related* problems that a
187189
- **IO problems**
188190

189191
Queries might be waiting for the pages to be written to the data or log files. In this case, check the `INSTANCE_LOG_RATE_GOVERNOR`, `WRITE_LOG`, or `PAGEIOLATCH_*` wait statistics in the DMV. See using DMVs to [identify IO performance issues](database/monitoring-with-dmvs.md#identify-io-performance-issues).
190-
- **TempDB problems**
192+
- **Tempdb problems**
191193

192-
If the workload uses temporary tables or there are TempDB spills in the plans, the queries might have a problem with TempDB throughput. See using DMVs to [identity TempDB issues](database/monitoring-with-dmvs.md#identify-tempdb-performance-issues).
194+
If the workload uses temporary tables or there are `tempdb` spills in the plans, the queries might have a problem with `tempdb` throughput. To investigate further, review [identify tempdb issues](database/monitoring-with-dmvs.md#identify-tempdb-performance-issues).
193195
- **Memory-related problems**
194196

195197
If the workload doesn't have enough memory, the page life expectancy might drop, or the queries might get less memory than they need. In some cases, built-in intelligence in Query Optimizer will fix memory-related problems. See using DMVs to [identify memory grant issues](database/monitoring-with-dmvs.md#identify-memory-grant-wait-performance-issues). For more information and sample queries, see [Troubleshoot out of memory errors with Azure SQL Database](database/troubleshoot-memory-errors-issues.md).
@@ -223,3 +225,4 @@ DMVs that track Query Store and wait statistics show results for only successful
223225
- [Diagnose and troubleshoot high CPU on Azure SQL Database](database/high-cpu-diagnose-troubleshoot.md)
224226
- [SQL Database monitoring and tuning overview](database/monitor-tune-overview.md)
225227
- [Monitoring Microsoft Azure SQL Database and Azure SQL Managed Instance performance using dynamic management views](database/monitoring-with-dmvs.md)
228+
- [Tune nonclustered indexes with missing index suggestions](/sql/relational-databases/indexes/tune-nonclustered-missing-index-suggestions)

0 commit comments

Comments
 (0)