What happens inside a database when you write a key and read it back — logs, LSM-trees, B-trees and column stores.
Two shell functions: db_set appends key,value to a file; db_get scans for the last line with that key. Appending is about as fast as writing can be.
Reads, though, scan the whole file — O(n). To read fast you need an index: an extra structure derived from the data that points to where things are.
Every index speeds up reads but slows writes, so databases make you choose which ones to create.
Reach the last step for the post-mortem: five takeaways from this chapter.