Strictly speaking from the point of view of speed, searching for single, exactly matching keys in a direct hash in memory is about as good as you can get if your data cannot be placed into an array. (i.e., it will be accessed only by a series of numerical keys, which form a predominantly adjacent range starting with 0.)
If you have several possible keys that may be required for the search (for example, the identifier of the name and employee) or if you need to perform a search that is not strictly based on equality (for example, βFind all employees with the last nameβ Smith β), then you will slow down significantly due to the need to search through hash keys, and the database will begin to look much better.
Another factor in overall performance is that you mentioned that your hashes are "stored in multiple file locations." If you make only one or several requests, reading hashes into memory from these files also takes time, which again tends to favor the use of a database, which will minimize the amount of unnecessary data that is read from disk.
Thus, it depends on how you need to access your data and your access patterns.
source share