Hmm, one million records is relatively big, but not really something huge by today's criteria (although it depends also on the size of the records, obviously, and on your hardware). And it is likely to fit into a hash. And a hash in memory is very likely to be at least 100 times more efficient than a SQL database. In other words, use a database if you really have to, use hashes (or nested hashes or other composite data structure in memory, whatever) if you can.