Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Commit 6a42aaa

Browse files
20220506 query store hints best practices
1 parent 7877a9e commit 6a42aaa

1 file changed

Lines changed: 26 additions & 14 deletions

File tree

docs/relational-databases/performance/query-store-hints-best-practices.md

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,48 +24,59 @@ This article details best practices for using [Query Store hints (Preview)](quer
2424
- For more information on configuring and administering with the Query Store, see [Monitoring performance by using the Query Store](monitoring-performance-by-using-the-query-store.md).
2525
- For information on discovering actionable information and tune performance with the Query Store, see [Tuning performance by using the Query Store](tune-performance-with-the-query-store.md).
2626

27-
Learn how to improve bulk loading with Query Store hints with this 14-minute video:
28-
29-
> [!VIDEO https://channel9.msdn.com/Shows/data-exposed/using-query-store-hints-to-optimize-memory-grants-improving-performance/player?WT.mc_id=dataexposed-c9-niner]
30-
31-
## Best use cases for Query Store hints
27+
## Use cases for Query Store hints
3228

3329
Consider the following use cases as ideal of Query Store hints. For more information, see [When to use Query Store hints](query-store-hints.md#when-to-use-query-store-hints).
3430

3531
> [!CAUTION]
3632
> Because the SQL Server Query Optimizer typically selects the best execution plan for a query, we recommend only using hints as a last resort for experienced developers and database administrators. For more information, see [Query Hints](../../t-sql/queries/hints-transact-sql-query.md).
3733
38-
### Code cannot be changed
34+
### When code cannot be changed
3935

4036
Using Query Store hints allows you to influence the execution plans of queries without changing application code or database objects. No other feature allows for you to apply query hints quickly and easily.
4137

38+
You can use Query Store hints, for example, to benefit ETLs without redeploying code. Learn how to improve bulk loading with Query Store hints with this 14-minute video:
39+
40+
> [!VIDEO https://channel9.msdn.com/Shows/data-exposed/using-query-store-hints-to-optimize-memory-grants-improving-performance/player?WT.mc_id=dataexposed-c9-niner]
41+
42+
Query Store hints are lightweight query tuning methods, but if a query becomes problematic it should be addressed with more substantial code changes. If you are regularly finding the need to apply Query Store hints to a query, consider a larger query rewrite. The SQL Server Query Optimizer typically selects the best execution plan for a query, we recommend only using hints as a last resort for experienced developers and database administrators.
43+
4244
For information on which query hints can be applied, see [Supported query hints](../system-stored-procedures/sys-sp-query-store-set-hints-transact-sql.md#supported-query-hints).
4345

44-
### High transaction load, mission critical code
46+
### Under high transaction load or with mission critical code
4547

4648
If code changes are impractical because of high uptime requirements or transactional load, Query Store hints can apply query hints to existing query workloads quickly. Adding and removing Query Store hints is easy.
4749

4850
Query Store hints can be added and removed to batches of queries to adjust performance for windows timed for bursts of exceptional workload.
4951

50-
### Replacement for plan guides
52+
### As a replacement for plan guides
5153

5254
Previous to Query Store hints, a developer would have to rely on [plan guides](plan-guides.md) to accomplish similar tasks, which can be complex to use. Query Store hints are integrated with Query Store features of SQL Server Management Studio (SSMS), for visual exploration of queries.
5355

5456
With plan guides, searching through all plans using query snippets is necessary. The Query Store hints feature does not require exact matching queries to impact the resulting query plan. Query Store hints can be applied to a `query_id` in the Query Store dataset.
5557

5658
Query Store hints override hard-coded statement-level hints and existing plan guides.
5759

58-
## Query Store hints caveats
59-
60-
Query Store hints are lightweight query tuning methods, but if a query becomes problematic it should be addressed with more substantial code changes. If you are regularly finding the need to apply Query Store hints to a query, consider a larger query rewrite. The SQL Server Query Optimizer typically selects the best execution plan for a query, we recommend only using hints as a last resort for experienced developers and database administrators.
61-
6260
### Consider a newer compatibility level
6361

6462
Query Store hints can be a valuable method when a newer database compatibility level is not available to you due to vendor specification or larger testing delays, for example. When a higher compatibility level is available to a database, consider upgrading the database compatibility level to take advantage of the latest performance optimizations and features of SQL Server.
6563

64+
## Query Store hints considerations
65+
66+
Consider the following scenarios when deploying Query Store hints.
67+
6668
### Data distribution changes
6769

68-
Plan guides, forced plans via the Query Store, and Query Store hints override the optimizer's decision making. For example, if a Query Store hint helps a query in previous data distribution, it may be counter-productive if large-scale DML operations change the data. A new data distribution may cause the optimizer to make a better decision than the hint. This scenario is the most common consequence of forcing plan behavior.
70+
Plan guides, forced plans via the Query Store, and Query Store hints override the optimizer's decision making. The Query Store hint may be beneficial now, but not in the future. For example, if a Query Store hint helps a query in previous data distribution, it may be counter-productive if large-scale DML operations change the data. A new data distribution may cause the optimizer to make a better decision than the hint. This scenario is the most common consequence of forcing plan behavior.
71+
72+
### Regularly re-evaluate your Query Store hints strategy
73+
74+
Re-evaluate your existing Query Store hints strategy in the following cases:
75+
76+
- After known large data distribution changes.
77+
- When the service level objective (SLO) of your Azure SQL Database or Managed Instance or virtual machine has changed.
78+
- Where plan fixing has become long-lived. Query Store hints are best used for short-term fixes.
79+
- Unexpected performance regressions.
6980

7081
### Broad impact potential
7182

@@ -79,8 +90,9 @@ Applying the RECOMPILE query hint with Query Store hints is not supported when t
7990

8091
The RECOMPILE hint is not compatible with forced parameterization set at the database level. If the database has forced parameterization set, and the RECOMPILE hint is part of the hints string set in Query Store for a query, the Database Engine will ignore the RECOMPILE hint and will apply other hints if leveraged.
8192

82-
<!-- t63 warning-->
93+
For information on which query hints can be applied, see [Supported query hints](../system-stored-procedures/sys-sp-query-store-set-hints-transact-sql.md#supported-query-hints).
8394

95+
<!-- t63 warning-->
8496

8597
## See also
8698

0 commit comments

Comments
 (0)