L3VLUP
Atlas

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.

Open the source at 1:30 to 8:30 (opens in a new tab)Checked against the clip · reviewed 2026-10-16

Connected ideas

Concepts

Put it to work on L3VLUP

More like this