Why is my page-fill factor very low despite using integers for keys in a btree database?
This is usually the result of using integer keys on little-endian architectures such as the x86. Berkeley DB’s default key comparison function, the code that is used to order the keys in your btree, treats the data in the DBT which you know to be an integer as a byte strings. As it turns out, little-endian integers don’t sort well when compared as though they were strings. For example, take the numbers 254 through 257.