Hash / B: Tree
The advantage of the hash is that you look faster when you are going to use the "=" operator to search.
If you intend to use things like "<" or ">" or anything else other than "=", you need to use B: Tree because it will be able to perform such searches.
Directory structure
If you have hundreds of thousands of files to be stored in the file system, and you put them all in one directory, you will reach the point where the index index of the directory will grow so much that it will take several minutes to add / remove a file from this directory. and you can even reach the point at which the index will not fit into memory, and you will not be able to add / remove or even touch the directory.
You can be sure that for the hash method foo, foo ("something") will always return the same, say, "grbezi". Now you use part of this hash to store the file, say, in gr / be / something. The next time you need this file, you just need to calculate the hash and it will be available directly. In addition, you get the fact that with a good hash function, the distribution of hashes in the hash space is pretty good, and for a large number of files they will be evenly distributed within the hierarchy, sharing the load.
source share