DATABASES · 9 MIN
SQL vs NoSQL, Indexes & Sharding
Pick the database by data shape and access pattern, then index and split it to scale.
ARCH explains
- SQL: tables, joins, strong transactions. NoSQL: documents, key-value or wide-column, flexible schemas.
- An index is a sorted lookup structure — reads get fast, writes get a little slower.
- Sharding splits rows across machines by a key, e.g. user_id % 4.
Real world: A library catalogue (index) and splitting books across branches by author letter (sharding).
Code
shards = 4
for uid in [7, 12, 33]:
print(uid, "→ shard", uid % shards)Output ›
7 → shard 3
12 → shard 0
33 → shard 1Try it in the online compiler →Checkpoint quiz
Adding an index usually makes…