This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: External Sorting 127 3. Since each page is read and written once per pass, the total number of page I/Os for sorting the file is 2 ∗ N ∗ (# passes ): (a) 2*10000*13 = 260000. (b) 2*20000*7 = 280000. (c) 2*2000000*6 = 24000000. 4. In Pass 0, d N/B e runs are produced. In Pass 1, we must be able to merge this many runs; i.e., B − 1 ≥ d N/B e . This implies that B must at least be large enough to satisfy B ∗ ( B − 1) ≥ N ; this can be used to guess at B , and the guess must be validated by checking the first inequality. Thus: (a) With 10000 pages in the file, B = 101 satisfies both inequalities, B = 100 does not, so we need 101 buffer pages. (b) With 20000 pages in the file, B = 142 satisfies both inequalities, B = 141 does not, so we need 142 buffer pages. (c) With 2000000 pages in the file, B = 1415 satisfies both inequalities, B = 1414 does not, so we need 1415 buffer pages. Exercise 13.2 Answer Exercise 13.1 assuming that a twoway external sort is used. Answer 13.2 Answer omitted. Exercise 13.3 Suppose that you just finished inserting several records into a heap file and now want to sort those records. Assume that the DBMS uses external sort and makes eﬃcient use of the available buffer space when it sorts a file. Here is some potentially useful information about the newly loaded file and the DBMS software available to operate on it: The number of records in the file is 4500. The sort key for the file is 4 bytes long. You can assume that rids are 8 bytes long and page ids are 4 bytes long. Each record is a total of 48 bytes long. The page size is 512 bytes. Each page has 12 bytes of control information on it. Four buffer pages are available....
View
Full Document
 Fall '12
 Dr.Vishak
 Sort, Pages, buffer pages

Click to edit the document details