Architectural Breakdown & AnalysisFAANG Aligned
These are three core optimization strategies to handle large volumes of database reads and writes. They operate at different levels of database management:
| Strategy | Location | Key Objective | How It Works |
|---|---|---|---|
| Indexing | Within a single table | Accelerates read queries | Creates lookup helpers (B-Tree or Hash index) mapping index keys to disk locations. Slightly slows down write operations. |
| Partitioning | Within a single database instance | Manages table layout | Splits a large table into smaller physical chunks (e.g. partition by Month) on the same disk for pruning. |
| Sharding | Across multiple physical databases | Scales write throughput & storage | Distributes database rows across distinct server nodes using a shard key (e.g. hash(user_id) % N). |
WARNING — Sharding Complexity
Sharding introduces significant overhead: JOIN queries across shards become extremely expensive, cross-shard transactions require distributed locks (2PC/Sagas), and re-balancing data when adding shards is complex.