• Home
  • Hash Based

    Hash-based index structures are a type of index structure used in relational database management systems (RDBMS) to provide efficient data retrieval based on hashed key values. These structures use a hash function to compute a hash value from the search key and map it to a location in the index structure.


    Here are two commonly used hash-based index structures:

    1. Hash Index:

    - In a hash index, a hash function is applied to the search key value to compute a hash code.
    - The hash code is then used as an index into a fixed-size array, called the hash table or hash bucket.
    - Each entry in the hash table typically contains a pointer to the disk location where the corresponding record is stored.
    - When searching for a record, the hash function is applied to the search key, and the resulting hash code is used to directly access the corresponding hash bucket.
    - If there are no collisions (i.e., different keys mapping to the same hash code), the retrieval can be performed in constant time.
    - However, collisions can occur, in which case additional techniques like chaining or open addressing are used to resolve them.


    2. Extendible Hashing:

    - Extendible hashing is a dynamic hashing technique that allows the hash index to grow or shrink dynamically as the data set changes.
    - In extendible hashing, the hash function generates a hash code with a fixed number of bits.
    - The hash code is divided into two parts: a global directory and a local directory.
    - The global directory maintains a list of pointers to the local directories, which in turn point to the actual data records.
    - Initially, the global directory and local directories are sparsely populated to minimize collisions.
    - As more records are inserted, the directories are dynamically expanded to accommodate new hash codes and redistribute the records.
    - Extendible hashing minimizes the number of collisions and provides efficient search and insertion operations.


    Hash-based index structures are particularly useful for point queries (exact match searches) where the search key is known. They can provide fast access to individual records if the hash function is well-designed and the distribution of keys is uniform. However, hash-based indexes may not perform well for range queries or partial match searches, as those require sequential scanning of the entire index.


    It's important to note that hash-based index structures may require additional storage space compared to other index structures like B+ trees, as they store the entire index in memory or on disk. Additionally, hash-based indexes can be sensitive to changes in the data distribution, and rehashing may be required in such cases to maintain performance.

    The selection of index structures, including hash-based indexes, should be based on careful analysis of the workload, data characteristics, and query patterns in order to achieve optimal performance for the specific database application.



    About the Author



    Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.

    We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc





     PreviousNext