| Start |
|---|
| JOIN Hints When you join two tables, SQL Server query optimizer (QO) can choose different types of joins that will be used in query:
QO will explore plans and choose the optimal operator for joining tables. However, if you are sure that you know what would be the optimal join operator, you can specify what kind of JOIN should be used. Inner LOOP join will force QO to choose Nested loop join while joining two tables: inner merge join will force MERGE join operator: inner hash join will force HASH join operator: |
| GROUP BY Hints When you use GROUP BY clause, SQL Server query optimizer (QO) can choose different types of grouping operators:
You can explicitly require that QO picks one or another aggregate operator if you know what would be the optimal. With OPTION (ORDER GROUP), QO will always choose Stream aggregate and add Sort operator in front of Stream aggregate if input is not sorted: With OPTION (HASH GROUP), QO will always choose Hash aggregate : |
| FAST rows hint Specifies that the query is optimized for fast retrieval of the first number_rows. This is a nonnegative integer. After the first number_rows are returned, the query continues execution and produces its full result set. |
| UNION hints When you use UNION operator on two query results, Query optimizer (QO) can use following operators to create a union of two result sets:
You can explicitly specify what operator should be used using OPTION() hint: |
| MAXDOP Option Specifies the max degree of parallelism for the query specifying this option. This option overrides the MAXDOP configuration option of sp_configure and Resource Governor. If MAXDOP is set to zero then the server chooses the max degree of parallelism. |
| INDEX Hints Index hints are used to force a query to use a specific index, instead of allowing SQL Server's Query Optimizer to choose what it deems the best index. In some cases you may gain benefits by specifying the index a query must use. Usually SQL Server's Query Optimizer chooses the best index suited for the query, but due to missing/outdated statistics or specific needs you can force it. |
Read Article
https://develop.horje.com/learn/1434/reference