15.17

Suppose you need to sort a relation of 40 gigabytes, with 4-kilobyte blocks, using a memory size of 40 megabytes. Suppose the cost of a seek is 5 milliseconds, while the disk transfer rate is 40 megabytes per second.

  1. Find the cost of sorting the relation, in seconds, with \(b_b = 1\) and with \(b_b = 100\).

  2. In each case, how many merge passes are required?

  3. Suppose a flash storage device is used instead of a disk, and it has a latency of 20 microsecond and a transfer rate of 400 megabytes per second. Recompute the cost of sorting the relation, in seconds, with \(b_b = 1\) and with \(b_b = 100\), in this setting.


I will use External Sort-Merge algorithm to sort the relation.

Let us call the given relation \(r\).

  1. Find the cost of sorting the relation, in seconds, with \(b_b = 1\) and with \(b_b = 100\).

Let \(b_r\) denote the number of blocks containing records of relation \(r\). Since the relation’s size is \(40\) GB and our block size is \(4\) KB, \(b_r = 10^7\).

Let \(M\) denote the number of blocks in main memory buffer available for sorting, that is, the number of disk blocks whose contents can be buffered in available main memory. Since our memory size is 40 MB, \(M = 10^4\).

Since the cost of seek is 5 milliseconds, \(t_S = 5 * 10^{-3}\) seconds.

Since the disk transfer rate is \(40\) MB/s, the number of seconds to transfer a single block is, \(t_T = 10 ^{-4}\) seconds.

Case 1: \(b_b = 1\)

Case 2: \(b_b = 100\)

  1. In each case, how many merge passes are required?

Case 1: \(b_b = 1\)

Case 2: \(b_b = 100\)

You could do it in Python as follows:

  1. Suppose a flash storage device is used instead of a disk, and it has a latency of \(20\) microsecond and a transfer rate of \(400\) megabytes per second. Recompute the cost of sorting the relation, in seconds, with \(b_b = 1\) and with \(b_b = 100\), in this setting.

For the flash storage device we are given: * \(t_S = 20 * 10^{-6}\) seconds * Since the disk transfer rate is \(400\) MB/s, the number of seconds to transfer a single block is, \(t_T = 10 ^{-5}\) seconds.

Case 1: \(b_b = 1\)

Case 2: \(b_b = 100\)