A query planner determines an efficient way to return the results described by declarative T-SQL. After parsing and algebraization produce a normalized query tree, it evaluates plans using object types, data types, statistics, indexes, and other metadata. section 1.2.1
Follow a query from the protocol layer through parsing, algebraization, the relational engine, and optimization. section 1.2.1
Avoid working against the planner:
- Do not assume a manually prescribed plan is better. The planner usually makes good decisions, although a suboptimal plan can harm performance. section 10.5
- Use query hints only in exceptional circumstances. Hints override optimizer decisions and can become overprescriptive. section 10.5
- Before forcing a join operator, investigate indexes and other causes; maintaining indexes and statistics helps the planner choose effectively. section 1.2.1 section 10.5
Nested Loops or Hash Join?
A join between Marketing.marketing.Impressions and MarketingArchive.dbo.ImpressionsArchive takes 19 seconds with Nested Loops. A Hash Join hint changes the selected operator, but creating indexes on the join columns is another remedy to investigate first.

