codingstuff.io
ExploreTutorialsProblemsCS Subjects
Get Started
ExploreTutorialsProblemsCS Subjects
Get Started
codingstuff.io

Master the art of building software through interactive tutorials, real-world problems, and guided projects.

Pune, Maharashtra, India

codingstuffmail@gmail.com

Product

  • Explore
  • Tutorials
  • Problems
  • CS Subjects

Company

  • About
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Sitemap

© 2026 codingstuff.io. All rights reserved.

Built with ❤️ for developers everywhere

/
/
All Subjects
🗄️

DBMS

23 chapters

1Intro & 3-Schema Architecture2ER Model & Diagrams3Generalization, Specialization & Aggregation4Relational Model & Codd's Rules5Relational Algebra6Tuple & Domain Relational Calculus7SQL: DDL, DML, DCL8Advanced SQL (Joins, Aggregates)9Views, Triggers & Stored Procedures10Functional Dependencies11Normalization (1NF, 2NF, 3NF)12BCNF & Lossless Decomposition13Transaction Concepts & ACID14Conflict & View Serializability15Concurrency Control & Locks162-Phase Locking (2PL)17Timestamp-Based Protocols18Indexing (Primary, Clustering)19B-Trees & B+ Trees20Hashing Techniques in DBMS21Database Recovery Techniques22NoSQL Databases Overview23Data Warehousing Concepts
SubjectsDBMS

Hashing Techniques in DBMS

Updated 2026-04-25
2 min read

Hashing Techniques in DBMS

Hashing provides $O(1)$ average-case access to records by applying a hash function to the search key, directly computing the address (bucket) where the record is stored.

1. Static Hashing

The number of buckets is fixed at database creation.

  • Hash Function: Maps the search key to a bucket number: $h(key) = key \mod N$ (where $N$ is the number of buckets).
  • Collision Handling: When two keys hash to the same bucket:
    • Open Addressing: Find the next available slot (linear probing, quadratic probing).
    • Chaining (Overflow Chains): Each bucket has a linked list of overflow records.

Problem: As the database grows, all buckets overflow, and long overflow chains degrade performance to $O(n)$.

2. Dynamic Hashing (Extendible Hashing)

Solves the problem of static hashing by allowing the hash table to grow and shrink dynamically.

  • Uses a directory (an array of pointers to buckets) and a global depth / local depth mechanism.
  • When a bucket overflows, it is split into two buckets, and the directory is doubled if necessary.
  • Only the overflowing bucket is reorganized; all other buckets remain untouched.

3. Linear Hashing

An alternative dynamic scheme that grows the hash table one bucket at a time in a round-robin fashion. No directory is needed. It uses a split pointer to track which bucket to split next.

4. Hashing vs Indexing (B+ Trees)

FeatureHashingB+ Tree Indexing
Equality queriesExcellent ($O(1)$)Good ($O(\log n)$)
Range queriesTerrible (must scan all buckets)Excellent (leaf nodes are linked)
SpaceCompactModerate overhead for tree structure
Best forPrimary key lookupsRange queries, sorted output

In practice, most modern databases default to B+ Tree indexes because they handle both equality and range queries well.



PreviousB-Trees & B+ TreesNextDatabase Recovery Techniques

Recommended Gear

B-Trees & B+ TreesDatabase Recovery Techniques