Skip to content

Commit 7fdcc79

Browse files
authored
Merge pull request #2111 from pmasl/master
Added context info iwrt QS usage during upgrades
2 parents 438b14b + 4dff400 commit 7fdcc79

5 files changed

Lines changed: 100 additions & 74 deletions

File tree

docs/relational-databases/performance/best-practice-with-the-query-store.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ manager: "jhubbard"
2323

2424
This topic outlines the best practices for using the Query Store with your workload.
2525

26-
## <a name="SSMS"></a> Use the Latest SQL Server Management Studio
26+
## <a name="SSMS"></a> Use the latest SQL Server Management Studio
2727
[!INCLUDE[ssManStudioFull](../../includes/ssmanstudiofull-md.md)] has set of user interfaces designed for configuring Query Store as well as for consuming collected data about your workload.
28-
Download the latest version of [!INCLUDE[ssManStudio](../../includes/ssmanstudio-md.md)] from : [https://msdn.microsoft.com/library/mt238290.aspx](https://msdn.microsoft.com/library/mt238290.aspx)
28+
Download the latest version of [!INCLUDE[ssManStudio](../../includes/ssmanstudio-md.md)] [here](https://docs.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms).
2929

3030
For a quick description on how to use Query Store in troubleshooting scenarios refer to [Query Store @Azure Blogs](https://azure.microsoft.com/en-us/blog/query-store-a-flight-data-recorder-for-your-database/).
3131

@@ -36,7 +36,8 @@ For more information, see [Azure SQL Database Query Performance Insight](https:/
3636

3737
## Using Query Store with Elastic Pool Databases
3838
You can use Query Store in all databases without concerns, in even densely packed pools. All issues related to excessive resource usage, that might have occurred when Query Store was enabled for the large number of databases in the Elastic Pools, have been resolved.
39-
## <a name="Configure"></a> Keep Query Store Adjusted to your Workload
39+
40+
## <a name="Configure"></a> Keep Query Store adjusted to your workload
4041
Configure Query Store based on your workload and performance troubleshooting requirements.
4142
The default parameters are good for a quick start but you should monitor how Query Store behaves over time and adjust its configuration accordingly:
4243

@@ -137,7 +138,7 @@ Navigate to the Query Store sub-folder under the database node in Object Explore
137138
|Overall Resource Consumption|Analyze the total resource consumption for the database for any of the execution metrics.<br />Use this view to identify resource patterns (daily vs. nightly workloads) and optimize overall consumption for your database.|
138139
|Top Resource Consuming Queries|Choose an execution metric of interest and identify queries that had the most extreme values for a provided time interval. <br />Use this view to focus your attention on the most relevant queries which have the biggest impact to database resource consumption.|
139140
|Queries With Forced Plans|Lists previously forced plans using Query Store. <br />Use this view to quickly access all currently forced plans.|
140-
|Queries With High Variation|Analyze queries with high execution variation as it relates to any of the available dimensions, such as Duration, CPU time, IO, and Memory usage in the desired time interval.<br />Use this view to identify queries with widely variant performance that can be impacting user experience accross your applications.|
141+
|Queries With High Variation|Analyze queries with high execution variation as it relates to any of the available dimensions, such as Duration, CPU time, IO, and Memory usage in the desired time interval.<br />Use this view to identify queries with widely variant performance that can be impacting user experience across your applications.|
141142
|Tracked Queries|Track the execution of the most important queries in real-time. Typically, you use this view when you have queries with forced plans and you want to make sure that query performance is stable.|
142143

143144
> [!TIP]
@@ -273,7 +274,8 @@ The following table provides best practices:
273274
As a result, performance of your workload will be sub-optimal and Query Store might switch to read-only mode or might be constantly deleting the data trying to keep up with the incoming queries.
274275

275276
Consider following options:
276-
- Parameterize queries where applicable, for example wrap queries inside a stored procedure.
277+
278+
- Parameterize queries where applicable, for example wrap queries inside a stored procedure or sp_executesql. For more information on this topic, see [Parameters and Execution Plan Reuse](../../relational-databases/query-processing-architecture-guide.md#PlanReuse).
277279

278280
- Use the [**Optimize for Ad Hoc Workloads**](../../database-engine/configure-windows/optimize-for-ad-hoc-workloads-server-configuration-option.md) option if your workload contains many single use ad-hoc batches with different query plans.
279281

@@ -291,7 +293,8 @@ As a result, performance of your workload will be sub-optimal and Query Store mi
291293
Query Store associates query entry with a containing object (stored procedure, function, and trigger). When you recreate a containing object, a new query entry will be generated for the same query text. This will prevent you from tracking performance statistics for that query over time and use plan forcing mechanism. To avoid this, use the `ALTER <object>` process to change a containing object definition whenever it is possible.
292294

293295
## <a name="CheckForced"></a> Check the status of Forced Plans regularly
294-
Plan forcing is a convenient mechanism to fix performance for the critical queries and make them more predictable. However, as with plan hints and plan guides, forcing a plan is not a guarantee that it will be used in future executions. Typically, when database schema changes in a way that objects referenced by the execution plan are altered or dropped, plan forcing will start failing. In that case [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] falls back to query recompilation while the actual forcing failure reason is surfaced in [sys.query_store_plan &#40;Transact-SQL&#41;](../../relational-databases/system-catalog-views/sys-query-store-plan-transact-sql.md). The following query returns information about forced plans:
296+
297+
Plan forcing is a convenient mechanism to fix performance for the critical queries and make them more predictable. However, as with plan hints and plan guides, forcing a plan is not a guarantee that it will be used in future executions. Typically, when database schema changes in a way that objects referenced by the execution plan are altered or dropped, plan forcing will start failing. In that case [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] falls back to query recompilation while the actual forcing failure reason is surfaced in [sys.query_store_plan](../../relational-databases/system-catalog-views/sys-query-store-plan-transact-sql.md). The following query returns information about forced plans:
295298

296299
```tsql
297300
USE [QueryStoreDB];
@@ -304,10 +307,12 @@ JOIN sys.query_store_query AS q on p.query_id = q.query_id
304307
WHERE is_forced_plan = 1;
305308
```
306309

307-
For full list of reasons, refer to [sys.query_store_plan &#40;Transact-SQL&#41;](../../relational-databases/system-catalog-views/sys-query-store-plan-transact-sql.md). You can also use the **query_store_plan_forcing_failed** XEvent to track troubleshoot plan forcing failures.
310+
For full list of reasons, refer to [sys.query_store_plan](../../relational-databases/system-catalog-views/sys-query-store-plan-transact-sql.md). You can also use the **query_store_plan_forcing_failed** XEvent to track troubleshoot plan forcing failures.
308311

309312
## <a name="Renaming"></a> Avoid renaming databases if you have queries with Forced Plans
310-
Execution plans reference objects using three-part names (`database.schema.object`).
313+
314+
Execution plans reference objects using three-part names `database.schema.object`.
315+
311316
If you rename a database, plan forcing will fail which will cause recompilation in all subsequent query executions.
312317

313318
## See Also
43.2 KB
Loading

0 commit comments

Comments
 (0)