Try
↑ ↓ move↵ openesc close

Interview prep / B-trees

Junior · B-trees · System design interview question

A table has a hundred million rows in a B-tree with a branching factor of about 500. Roughly how many page reads is a point lookup?

Sketch your own answer first, then compare it with the one below.

A strong answer

About three to four. With 500 children per page, one level reaches 500 leaves, two levels reach 250 thousand, three levels reach 125 million. So a tree of height three or four covers the table.

In practice fewer reads go to disk. The root and often the second level are hot and stay in the buffer cache, so a lookup may do one or two real reads.

A good answer says the cost grows with the logarithm of the table size, base the branching factor, and that this base is large.

Sources

Learn it by running it

The b-trees and page writes lesson explains the mechanism behind this question, and its lab lets you change the parameters and watch the effect.

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms