SQLite Forum

Index Btree
Login
The byte-length of each index entry is (probably) different.  You can't easily
know what that byte-length is.

CS textbook treatment of b-trees typically assumes each entry within a single
b-tree is the same size in bytes.  The b-tree is much easier to explain and
analyze that way.  But in the real world, data sizes vary.  So the entry sizes
vary.  Any particular page of a b-tree might have just a single entry or it
might have thousands of entries, depending on how many will fit.  And the
number of entries per page can vary widely among pages in the same b-tree.

So, for SQLite, if you want to know:

  1.  The number entries in a b-tree
  2.  The sizes of all entries in the b-tree
  3.  The depth of the b-tree
  4.  The number of pages in the b-tree

Then you have to walk the b-tree.  There are no shortcuts.