












































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This lecture is about Database systems, delivered by Philip Bohannon in University of California at California. External Sorting, Brian Cooper, Sort, Quicksort, Mergesort, Heapsort, Selection Sort, Insertion Sort, Radix Sort, Bubble Sort, 2-way Sort, Double Buffering, Clustered B Tree
Typology: Slides
1 / 52
This page cannot be seen from the preview
Don't miss anything!













































Blueberry Strawberry Kiwi Mango Orange Apple Grapefruit Banana Blueberry Strawberry Orange Mango Kiwi Grapefruit Banana Apple
Apple Banana Blueberry Grapefruit Kiwi Mango Orange Strawberry Apple Banana Blueberry Grapefruit Kiwi Mango Orange Strawberry Apple Banana Grapefruit Orange Blueberry Kiwi Mango Strawberry Apple Banana Grapefruit Orange Blueberry Kiwi Mango Strawberry
Pass 0: sort each page Pass 1: merge two pages into one run Pass 2: merge two runs into one run … Sorted!
Unsorted Sorted RAM Sorted Sorted RAM Sorted Sorted Sorted RAM Sorted
So O(N lg N) >> O(P lg P)
1,000,000 record file 8 KB pages 100 byte records = 80 records per page = 12,500 pages Plain merge sort: 41,863,137 disk I/O’s 2-way external merge sort: 365,241 disk I/O’s 4.8 days versus 1 hour
Two buffers to hold input records One buffer to hold output records When that buffer fills up, flush to disk
Set aside 100 MB for sort scratch space = 12,800 buffer pages
Thus reducing the number of passes Recall total cost: 2P * Passes