B-Tree vs Hash Table
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 element in a hash table is in O(1) . Why is a hash table not used instead of a b-tree in order to access data inside a database? The Surrican You can only access elements by their primary key in a hashtable. This is faster than with a tree algorithm ( O(1) instead of log(n) ), but you cannot select ranges ( everything in between x and y ). Tree algorithms support this in Log(n) whereas hash indexes can result in a full table scan O(n) . Also the