
Talking about databases... Databases are basically an append-only log with extra steps. Writes are just appending to the end. Makes it blazing fast, no random disk seeks. Reads? Without help, you end up scanning the whole file, which results in a painful O(n). So the solution is to add an index a hash map (or something similar) from key to byte offset on disk. Now reads become O(1). But there’s a tradeoff: every index costs you write speed. That’s why databases don’t index everything by default you choose based on your actual queries. Storage engines aren’t magic. They’re just data structures brutally optimizing the read/write/amplification trade-offs.























