Tutorial by Examples

When you join two tables, SQL Server query optimizer (QO) can choose different types of joins that will be used in query: HASH join LOOP join MERGE join 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 ...
When you use GROUP BY clause, SQL Server query optimizer (QO) can choose different types of grouping operators: HASH Aggregate that creates hash-map for grouping entries Stream Aggregate that works well with pre-ordered inputs You can explicitly require that QO picks one or another aggregate ...
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. select OrderID, AVG(Quantity) from Sales.OrderLines group by OrderID OPTION ...
When you use UNION operator on two query results, Query optimizer (QO) can use following operators to create a union of two result sets: Merge (Union) Concat (Union) Hash Match (Union) You can explicitly specify what operator should be used using OPTION() hint: select OrderID, OrderDate, Ex...
Specifies the max degree of parallelism for the query specifying this option. SELECT OrderID, AVG(Quantity) FROM Sales.OrderLines GROUP BY OrderID OPTION (MAXDOP 2); This option overrides the MAXDOP configuration option of sp_configure and Resource Governor. If MAXDOP is set to zero then...
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...

Page 1 of 1