IT lexicon › Database › Join Algorithm

Join Algorithm

Database På svenska → Updated: 2026-11-11

A method for combining rows from two or more tables based on a condition.

A JOIN is central to relational databases — it combines rows from two tables where a condition matches, like ORDER.customer_id = CUSTOMER.id. But how does the engine do this efficiently at scale? Three main algorithms exist. Nested-loop-join is simplest: for each row in the outer table, scan the inner table for matches (slow if the inner table is large, unless it's indexed). Hash-join builds a hash table of the smaller relation and probes it — fastest for large data. Sort-merge-join sorts both relations first, then scans them together. The engine picks the algorithm based on table sizes, available indexes, memory, and the optimizer's cost estimate.

← Back to the lexicon