The essential difference from traditional disks
A Hard Disk Drive (HDD) is a “in-place overwritable” magnetic medium, whereas NAND Flash cannot be overwritten in place — it must be erased before writing, and the erase unit is far larger than the write unit. This asymmetry shapes all of SSD engineering and directly influences database write strategies.
Storage cell: the floating-gate transistor
Each NAND storage cell is a floating-gate transistor that represents bits by trapping charge:
Control Gate
│
┌────┴────┐
│ Floating │ ← inject electrons = 0 (threshold voltage rises)
│ Gate │ ← release electrons = 1 (threshold voltage drops)
└────┬────┘
tunnel oxide
│
Substrate
- Electrons injected into the floating gate (tunneling) → high threshold voltage → recorded as 0
- Released electrons → low threshold voltage → recorded as 1
- Charge can be retained for years (but leaks; needs ECC correction)
SLC / MLC / TLC / QLC: a cell stores 1/2/3/4 bits. Higher density is cheaper but wears faster and is slower.
Pages, blocks, and the read/write/erase asymmetry
NAND uses pages (4-16KB) as the read/write unit, but blocks (tens to hundreds of pages) as the erase unit:
Block (e.g. 256 pages)
┌────┬────┬────┬─────┬────┐
│Page│Page│Page│ ... │Page│ ← read/write by page
└────┴────┴────┴─────┴────┘
↑ entire block erased together
Key constraints:
| Operation | Min unit | Speed |
|---|---|---|
| Read | page | fast (~100 μs) |
| Program (write) | page | medium (~200 μs) |
| Erase | block | slow (~2-3 ms) |
Cannot update in place: to modify a page, the whole block must be read into cache, erased, then rewritten with new data.
FTL: the Flash Translation Layer
The SSD controller runs an FTL (Flash Translation Layer) that maps the OS’s “Logical Block Address (LBA)” to physical pages, and externally pretends to be an in-place overwritable block device:
OS: write LBA 100 → overwrite
│
▼
FTL: actually write to new physical page Pnew,
mark old page Pold as invalid,
update mapping 100 → Pnew
- Write Amplification: 4KB logical write may become 16KB+ physically (including block reclaim)
- The mapping table lives in DRAM (flushed back on power loss via capacitor protection)
Write amplification and garbage collection
Valid (valid) and invalid (invalid) pages are mixed within a block. Reclaiming requires:
1. Pick a block with many invalid pages
2. Relocate the valid pages elsewhere
3. Erase the whole block
4. Mark it free
Before: [V][I][V][I][I] V=valid I=invalid
After: [V][V] → saved elsewhere
Erased: [ ][ ][ ][ ][ ] block cleared, writable again
Write Amplification Factor = physical writes / host writes. Random small writes and high fill rates amplify write amplification, slowing the SSD and accelerating wear.
Wear leveling
Each block has a limited erase count (TLC ~1000-3000, SLC tens of thousands). The FTL balances erases across blocks via wear leveling:
- Dynamic: prefer less-erased blocks for new data
- Static: occasionally relocate “read-only cold data” so long-untouched blocks also wear
TRIM and read disturb
- TRIM/DISCARD: the OS tells the SSD an LBA is deleted, so the FTL marks the page invalid early, reducing later garbage-collection overhead. Timely TRIM after
VACUUM/ file deletion matters for databases. - Read Disturb: frequently reading a page may disturb the charge of other pages in the same block; the controller periodically relocates them.
Implications for databases
| SSD trait | Database response |
|---|---|
| sequential write ≫ random write | WAL sequential append; LSM sequential Compaction |
| write amplification | avoid frequent small random updates; batch writes |
| no in-place update | append write / COW (WAL, B-tree HOT) |
| TRIM matters | TRIM after deletes; periodic vacuum |
| limited endurance | choose high-endurance drives for write-heavy (TLC/enterprise) |
SSDs make “random reads” no longer fatal (≈100× faster than HDD), but random writes remain a relative weakness — the core motivation behind WAL and LSM-Trees.
References
- Understanding SSDs, Chen, Xue, et al.
- OpenSSD: Introduction to NAND Flash
- PostgreSQL WAL Documentation