In MySQL, an index type is a b-tree, and access an element in a b-tree is in logarithmic amortized time O(log(n)).
On the other hand, accessing an eleme
The time complexity of hashtables is constant only for sufficiently sized hashtables (there need to be enough buckets to hold the data). The size of a database table is not known in advance so the table must be rehashed now and then to get optimal performance out of an hashtable. The rehashing is also expensive.