IT lexicon › Database › Sort-merge join

Sort-merge join

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

A join algorithm that sorts both input tables on the join key and then merges them in a single pass.

Sort-merge is practical when there is no index on the join column or when the join is outer. The algorithm sorts both tables by join key, then iterates through them in parallel, emitting rows where keys match. Cost depends on sorting, not input size.

Ingres and other early relational databases often had only sort-merge available. Modern databases use it when hash joins don't fit or when the output must already be sorted.

← Back to the lexicon