Consider the following scenario: • A table has 800,000,000 rows. • Each index block is 4 kilobytes. • Each index entry is 40 bytes. • Assume 1 kilobyte is approximately 1,000 bytes.Assuming the index is dense and sorted, a binary search for one row reads approximately how many blocks?
Question
Consider the following scenario: • A table has 800,000,000 rows. • Each index block is 4 kilobytes. • Each index entry is 40 bytes. • Assume 1 kilobyte is approximately 1,000 bytes.Assuming the index is dense and sorted, a binary search for one row reads approximately how many blocks?
Solution
To solve this problem, we first need to determine how many index entries fit into one block. Given that each index block is 4 kilobytes (or approximately 4,000 bytes) and each index entry is 40 bytes, we can fit 4,000 / 40 = 100 index entries per block.
Next, we need to determine how many blocks are needed to store all the rows in the table. Given that the table has 800,000,000 rows and each block can store 100 index entries (or rows), we need 800,000,000 / 100 = 8,000,000 blocks.
Finally, we need to determine how many blocks a binary search would need to read to find one row. In a binary search, the number of steps (or blocks read) is approximately equal to the base-2 logarithm of the number of items being searched. So, we need to calculate log2(8,000,000).
Using a calculator, log2(8,000,000) is approximately 23. Therefore, a binary search for one row reads approximately 23 blocks.
Similar Questions
Consider the following scenario: • A table is sorted on indexed column and has 10,000,000 rows. • Each row is 200 bytes. • Table and index blocks are 4 kilobytes. • Assume 1 kilobyte is approximately 1,000 bytes.Assuming the index is sparse, how many entries are in the index?
Assume the table has no index. What is the maximum number of blocks necessary to process the SELECT with a table scan?
A table occupies 3000 blocks. FlightNumber is the primary key. A single-level index on FlightNumber occupies 100 blocks. The WHERE clause of a SELECT specifies "FlightNumber = 3750".What is the maximum number of blocks necessary to process the SELECT with an index scan?
What is the time complexity of Binary Search in the worst case?
Worst case efficiency of binary search is
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.