Part 3 of 4 · 2 min read
Fixed-size blocks
Why storage is always accessed in fixed-size chunks, never one byte at a time.
Fixed-size blocks
Think of a library that only ever lends out whole shelves at a time. It never lends a single book plucked individually, even if a reader only wanted one.
In plain words: disks and databases read and write data in fixed-size blocks, commonly 4 or 8 kilobytes, never a single byte at a time. Even changing one small value requires reading the entire block containing it, modifying that one value in memory, and writing the entire block back.
A worked example. Updating a single price column in one row still requires reading and rewriting the full 8-kilobyte block that row lives in, which likely holds several other rows too.
The key lines. No SQL; block size is a storage-engine configuration detail, usually invisible to ordinary query-writing.
Block (page)
A block, also called a page, is the fixed-size unit disks and databases read and write in, commonly 4 or 8 kilobytes. Even a tiny change requires reading and rewriting the whole block containing it.
Example: a one-byte change to a price value still triggers a full block read and a full block write, since there is no smaller unit of I/O available.
For the curious Why this unit was chosen this size
Block sizes are chosen to balance two costs: too small, and the fixed overhead of each I/O operation dominates; too large, and a tiny change wastes disproportionate I/O rewriting mostly-unrelated data. 4 and 8 kilobytes are common because they match typical operating system page sizes well, keeping the database and the operating system's own memory management working together efficiently.
Quick notes
- RAID combines multiple disks into one logical unit, trading off speed, capacity and failure protection.
- RAID 0 stripes for speed with no redundancy; RAID 1 mirrors for protection; RAID 5 stripes with parity for some protection with less capacity loss than mirroring.
- Storage is always read and written in fixed-size blocks, never a single byte at a time.
- Even a tiny change requires a full block read and a full block write.
- Block size balances per-operation overhead against the waste of rewriting unrelated data for a small change.