Berkeley DB, if used via the BerkeleyDB API and not a tied DB_File approach, is faster than an RDBMS. An RDBMS is flexible, and lets you answer more questions without changing things around. The kind of questions you want to answer may be possible to handle by using a sorted BTree for your BerkeleyDB database, but this will involve stepping through the records. They would be likely be simpler with an RDBMS.
in reply to Wisdom sought on migrating from text files to Berkeley DB or SQL
For the record, eToys.com used Berkeley DB for caching data, and imdb.com used to use it extensively. I don't know if they still do.