//
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.
The number of buckets is fixed at database creation.
Problem: As the database grows, all buckets overflow, and long overflow chains degrade performance to $O(n)$.
Solves the problem of static hashing by allowing the hash table to grow and shrink dynamically.
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.
| Feature | Hashing | B+ Tree Indexing |
|---|---|---|
| Equality queries | Excellent ($O(1)$) | Good ($O(\log n)$) |
| Range queries | Terrible (must scan all buckets) | Excellent (leaf nodes are linked) |
| Space | Compact | Moderate overhead for tree structure |
| Best for | Primary key lookups | Range queries, sorted output |
In practice, most modern databases default to B+ Tree indexes because they handle both equality and range queries well.