It's the last working day of the month and salaries are landing. In a few hours a bank's database takes in hundreds of thousands of deposits, transfers and balance checks. You open your app, tap "statement", and your last thirty transactions appear before you've put the phone down. Somewhere in the server room a hard disk failed at two in the afternoon. Nobody outside the IT department noticed, and no taka went missing.
Three quiet pieces of engineering made that afternoon boring, in the best sense. The data sat on storage chosen and arranged with care. The disks were grouped so that one could die without losing anything. And every query you sent was turned, in a fraction of a millisecond, into a plan for reaching your rows with as few disk reads as possible. This chapter opens up all three.
By the end you'll be able to put the storage hierarchy in order and say why it matters. You'll work out a disk's capacity, even when it has zones, and the time one block read takes. You'll explain the buffer manager and which block it throws out, compute a blocking factor and a file's size, and choose between heap, sequential, indexed-sequential, hashed and clustered files by what each costs in block reads. You'll pick and defend a RAID level with capacity, parity and IOPS figures. And you'll follow a query from SQL text to an evaluation plan, price each join algorithm, and read a real plan with its cost and row estimates.
We'll go in ten parts, from the hardware up to the query planner. The indexing lesson showed how an index finds a row; here we look at the floor that index stands on, and at the planner that decides when to use it.