Sort-Merge Join: The 'Line Up and Walk' Join
A sort-merge join is like merging two sorted lines of people. It's efficient when tables are already sorted on the join key or memory is tight. The footgun: if data isn't pre-sorted, the initial sort can make it slower than other join methods.
Think of a sort-merge join like merging two sorted lines of people. You walk both lines, comparing one person at a time. It's highly efficient when tables are already sorted on the join key (e.g., from an index) or when memory is too tight for a hash join. The common footgun is forgetting the cost: if data isn't pre-sorted, the initial sort can dominate execution time, often making a hash join the faster choice for unsorted data.
Read the original → Wikipedia: Sort-merge join
- #database
- #sql
- #architecture
- #algorithms
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.