Appendix B: Logical vs. Physical Offset
Linked from the SSTables and sparse indexes part.
Logical means position in the file's own address space — "byte N from the start of this file" — a clean 0-to-size number line, regardless of where those bytes sit on disk. Physical is the actual disk block that byte lives in. Logical bytes 0–4095 might map to physical block 5000 while logical bytes 4096–8191 map to physical block 9000, nowhere near it. The inode/extent map is that logical→physical translation.
What "the file's own address space" means
An address space is a set of addresses that mean something only inside one context. "Byte 4096" is not a location in the universe — you must say of what. Every file gets its own private number line, and users.sst byte 0 and orders.sst byte 0 are both "byte 0" yet are entirely different physical bytes. That is why a read is pread(fd, buf, len, offset): the fd names the address space, the offset is a coordinate inside it. Same as "apartment 4B" — meaningless until you name the building.
Four properties define the fiction the filesystem maintains for each file:
| Starts at 0 | wherever the file actually lives on the device |
|---|---|
| Contiguous, no holes | offsets 4095 and 4096 are adjacent here, possibly megabytes apart physically |
| Stable | defrag, CoW or wear leveling relocates blocks; byte 5000 is still byte 5000 |
| Grows at the end | appending extends the line, never renumbers what exists |
The storage engine speaks only this language — "4 KB at offset 20480 of this SSTable." A sparse-index entry is a number in this space and nothing more; the engine never learns which device block that is.
When an insert "shifts every subsequent record to a new logical offset," no bytes have moved on disk yet — only their identity has (the byte that was logical offset 5000 is now logical offset 5000 + len(new record)). Making that renumbering real requires physically rewriting content so the right bytes land at the new offsets. That rewrite is the actual O(n) cost. Physical scatter changes how efficiently the OS locates the affected blocks — not how much renumbering must happen.
Note there is no escape by redirection: because the space is defined as contiguous-from-0, you cannot leave the bytes put and point offset 20480 somewhere else. That constraint is exactly what a B-tree sidesteps by locating the next page through a stored pointer rather than through implied adjacency.
The same pattern recurs one layer up: a process's virtual memory is its own address space, page tables translate it to physical RAM, and two processes both hold a valid 0x7fff… meaning different things. Indirection layer, private numbering, translation table — same shape every time.