TechniqueFrameworkSoftware engineering
An index turns a table scan into a handful of page reads, paid for in write speed and disk
Hussein Nasser · B-tree vs B+ tree in Database Systems
The idea
A query with no index reads every row. Hussein Nasser builds up from scanning a large table to why a tree is the structure you want: a sorted structure whose nodes are pages, so that finding a row means reading a few pages from the root down rather than all of them. The cost is on the other side. Every write has to maintain the tree, and every index takes disk. The interview question of why a query is slow is usually answered by the absence of an index; the harder question, why a write is slow, is often answered by the presence of too many.
An index buys read speed with write speed and disk; add one for the query you run most and remove the ones you never use.
When it works
Database questions in engineering and data interviews, and any slow query on a desk.
When it may fail
Indexes are one lever among many, and a query that is slow for other reasons, a bad join, a missing statistic, will not be rescued by one. The plan tells you which case you have.
How to use it
Asked why a query is slow, ask for the execution plan and look for a scan. Asked why a write is slow, count the indexes the write has to maintain. Say the trade-off out loud.
Where it came from
Video B-tree vs B+ tree in Database Systems · Hussein Nasser
What the source says. Hussein Nasser builds up from scanning a large table to why a tree is the structure you want, and what the tree costs.
Connected ideas
Says something similar
Consensus is agreeing on one value when any machine may crash and the network may lieAsk what a consensus protocol assumes about crashes and the network; its guarantee is only as strong as those assumptions.
Says something similar
In dynamic programming the hard part is finding the subproblem, not the memoisationFind the subproblem and the recurrence first; the implementation is mechanical once the structure is clear.
Concepts
Put it to work on L3VLUP
More like this
- FrameworkSoftware engineeringBook
Complexity is what you must hold in your head to make a safe change
Judge a design by how much a reader must understand to change it safely, and prefer deep modules behind small interfaces.
From A Philosophy of Software Design · John Ousterhout
- TechniqueSoftware engineeringVideo located
In a distributed system every request may arrive twice, so make the second one harmless
Design every retryable operation so that doing it twice has the same effect as doing it once; the network will test this for you.
From Build a Robust Payments Service Using Idempotency Keys · Arpit Bhayani
- ArgumentSoftware engineeringBook
Speed and stability rise together. The trade-off is the myth
The practices that make shipping frequent are the ones that make it safe, so do not trade one for the other.
From Accelerate · Nicole Forsgren, Jez Humble and Gene Kim
- FrameworkArtificial intelligenceVideo located
The context window is not the constraint people think it is; attention across it is
A long window degrades before it fills; curate and order what goes in rather than relying on size.
From Why LLMs Get Dumb (Context Windows Explained) · NetworkChuck