External Merge Sort and Multi-way Merging
A deep dive into how database engines sort datasets that exceed memory capacity using disk-based merge sort, run generation, and replacement selection.
Sample Questions
What is the primary reason for using External Merge Sort instead of Internal Sort algorithms like Quicksort?
- The data size exceeds the available RAM
- External Merge Sort is always faster than Quicksort
- Internal sorts cannot handle duplicate values
- External Merge Sort uses fewer CPU cycles
In the first phase (Pass 0) of External Merge Sort with M available buffer pages, how many pages are typically read and sorted at once?
- 1 page
- M pages
- M-1 pages
- sqrt(M) pages
If a file has N pages and there are M buffer pages available, how many initial runs are produced after Pass 0?
- N/M
- N-M
- N*(M-1)
- log(N/M)