You can access elements only by their primary key in the hash table. This is faster than using the tree algorithm ( O(1) instead of log(n) ), but you cannot select ranges (all between x and y ). Tree algorithms support this in log(n) , where a full scan of the O(n) table can be performed as a hash index. Also, the constant overhead of hash indexes is usually greater (which is not a factor in theta notation, but it still exists). In addition, tree algorithms are usually easier to maintain, grow with data, scales, etc.
Hash indexes work with predefined hash sizes, so you get some "buckets" in which objects are stored. These objects loop again to really find the right one inside this section.
So, if you have small sizes, you have a lot of overhead for small elements, large sizes lead to further scanning.
Modern hash table algorithms usually scale, but scaling can be inefficient.
There are really scalable hashing algorithms. Do not ask me how this works - this is also for me. AFAIKs, they evolved from scalable replication, where re-hashing is not easy.
It is called RUSH - R. < , and these algorithms are called RUSH algorithms.
However, there may be a point at which your index is larger than your hash size, and your whole index needs to be rebuilt. This is usually not a problem, but for huge huge databases it can take several days.
Compilation for tree algorithms is small, and they are suitable for almost every use case and, therefore, by default.
However, if you have a very accurate use case, and you know exactly what you just need, you can use hash indices.