Sql Server: Use Query Hints
- Posted by Sqltimes
- On November 15, 2013
- 0 Comments
Quick one today
Query hints are sometimes very useful. They are great when you need them, but you want to be careful in your usage. Test thoroughly before embarking on this path. As MSDN says, “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.”
Query hints impact the entire query. They affect the way the entire query is executed (query plan, etc), unlike table hints that affect only the table or the indexed view. OPTION clause is used to specify query hints.
Below are some of the examples to using Query Hints in queries.
1
2
3
4
5
6
|
SELECT ID, Name , Activity FROM dbo.ActivityExtLog AS AL INNER JOIN dbo.Activity AS A ON A.ID = AL.ID OPTION (MAXDOP 8) GO |
Hope this helps,
_Sqltimes
0 Comments