Another solution for cases where you don't add new entries all the time and can reindex the whole database every once in a while instead: use cdb. There's a nice description of the internals and how it works. http://www.unixuser.org/~euske/doc/cdbinternals/index.html It guarantees access in two disk reads.