Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6476061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:46:45+00:00 2026-05-25T06:46:45+00:00

In MySQL, an index type is a b-tree, and access an element in a

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:46:46+00:00Added an answer on May 25, 2026 at 6:46 am

    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 constant overhead of hash indexes is usually bigger (which is no factor in theta notation, but it still exists).
    Also tree algorithms are usually easier to maintain, grow with data, scale, etc.

    Hash indexes work with pre-defined hash sizes, so you end up with some "buckets" where the objects are stored in. These objects are looped over again to really find the right one inside this partition.

    So if you have small sizes you have a lot of overhead for small elements, big sizes result in further scanning.

    Todays hash tables algorithms usually scale, but scaling can be inefficient.

    There are indeed scalable hashing algorithms. Don’t ask me how that works – its a mystery to me too. AFAIK they evolved from scalable replication where re-hashing is not easy.

    Its called RUSH – Replication Under Scalable Hashing, and those algorithms are thus called RUSH algorithms.

    However there may be a point where your index exceeds a tolerable size compared to your hash sizes and your entire index needs to be re-built. Usually this is not a problem, but for huge-huge-huge databases, this can take days.

    The trade off for tree algorithms is small and they are suitable for almost every use case and thus are default.

    However if you have a very precise use case and you know exactly what and only what is going to be needed, you can take advantage of hashing indexes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using MySQL and I have a table with an index that is
My MySQL table is simple. I have 3 fields: an index a url a
I have got a simple MySQL table and primary index (id) is not numbered
I have an incredibly simple query (table type InnoDb) and EXPLAIN says that MySQL
Mysql uses B+ tree for implementing indexes. Lets say my primary index is of
I'm having trouble getting a decent query time out of a large MySQL table,
I have a MySQL table with 4 columns Column Type Null Default ---------------------------------- id
In my MySQL database I see these statistics: Type Usage Data 16,384 Bytes Index
I have a MySQL table with just a single text type column with lots
I’m trying to create a FULLTEXT index on an attribute of a table. Mysql

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.