3.7. JOIN Algorithms

The one operation that defines an RDBMS more than any other is a JOIN between tables. This was one of Dr. Codd’s basic operators, and various forms of joins are given keywords in SQL. Every SQL engine will have internal differences, but there are some common algorithms for doing JOINs. Picking the best algorithm to use for each query is the job of the optimizer. The programmer should not spend much time worrying about those choices, but he should know something about the algorithms in the few situations where he needs to look at execution plan. All major SQL implementations have an EXPLAIN or other command that will display execution plan in a human-readable format.

In the old days, the nested-loop and the sort-merge join ...

Get Joe Celko's Thinking in Sets: Auxiliary, Temporal, and Virtual Tables in SQL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.