Two way Merge Sort

  • Number of passes:
  • IO:
    Sort in input buffer, write it to output buffer. When output buffer is full, write it to disk.


K way Merge Sort

  • is the total number of buffer pages available
  • Sort Phase: Read pages at a time and write sorted runs back to disk
  • Merge Phase: Combine up to runs in each pass
  • Passes:


Double Buffering

Prefetch the next run in the background and storing it in a second buffer while the system is processing the current run. To overlap disk IO and CPU time This optimization requires the use of multiple threads, since the prefetching should occur while the computation for the current run is happening.

Comparison Optimizations