liveBook · Manning

Physical join operator

As explained in 100 SQL Server Mistakes and How to Avoid Them

A physical join operator is an execution algorithm that implements a logical join between relational inputs.

Mistake: force the join operator that looks fastest today. A physical join operator is the execution algorithm used to implement a logical join, and the optimizer usually chooses among alternatives for different data conditions. Query hints should therefore be a last resort. section 10.5

The 19-second Nested Loops query

A join between Marketing.marketing.Impressions and MarketingArchive.dbo.ImpressionsArchive runs for 19 seconds with Nested Loops. Forcing Hash Join may help this execution, but it hard-codes a choice that can become poor as data, statistics, or workloads change.

Prefer investigation and maintainable fixes before forcing an operator:

  • Check whether statistics are current. section 10.5
  • Use plan freezing, Query Store hints, USE PLAN, HASH MATCH, or join hints only exceptionally. section 10.5

How 100 SQL Server Mistakes and How to Avoid Them covers it

How deep it goes
Defines operator choices and their data scenarios, then stops short of detailed execution internals.
Examples
Uses an Impressions join, a 19-second Nested Loops plan, a forced Hash Join, and an index on ImpressionUID.
What it assumes
Assumes basic SQL joins and query plans while introducing physical operators and optimizer intervention.
What you can do after
Diagnose join performance and apply safer alternatives before forcing a physical operator.
How it connects
Connects logical joins with query optimizers, query plans, query hints, statistics, and indexes.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of 100 SQL Server Mistakes and How to Avoid Them. The section links point to the parts of the book it draws on.