B-Tree vs Hash Table

后端 未结 5 607
轻奢々
轻奢々 2020-12-22 16:32

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

5条回答
  •  萌比男神i
    2020-12-22 16:57

    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.

提交回复
热议问题