A B+Tree is fast because each page holds many keys, so the tree stays shallow. Today you compute the fanout - the maximum keys a leaf and an internal node hold in a 4096-byte page - and set the small teaching order the split lessons will use.
Compute the maximum key count for a leaf and an internal node in a 4096-byte page.
The whole reason a B+Tree beats a binary tree on disk is fanout: because one 4096-byte page holds hundreds of keys, the tree branches hundreds of ways at each level, so even a million keys sit only three or four pages deep. Today’s numbers - 255 keys in a leaf, 340 in an internal node - are the concrete payoff of packing nodes into fixed pages.
Those are the real limits, but demonstrating a split with 255 keys would be miserable, so from here the tree uses a small teaching order: a node holds at most 3 keys and splits on the 4th. The mechanics are identical at order 3 and order 255 - only the numbers change - so pinning the split rules on tiny nodes is exactly as correct, and far easier to follow. The next chapter builds a working one-node index; the chapter after that makes it grow.
func leafCapacity(pageSize int) int {return (pageSize - leafHeader) / entrySize // 255}func internalCapacity(pageSize int) int {// 3 header + 8*N keys + 4*(N+1) children <= pageSizereturn (pageSize - 3 - 4) / (8 + 4) // 340}