Module 12a: Dynamic Hashing: Database System Concepts, 6 Ed
Module 12a: Dynamic Hashing: Database System Concepts, 6 Ed
Database System Concepts - 6th Edition 12.2 ©Silberschatz, Korth and Sudarshan
General Extendable Hash Structure
In this structure each bucket hold 2 entries.
i2 = i3 = i
i1 = i – 1
For entry 0 in ther bucket address table, number of pointers is i1 = i
Database System Concepts - 6th Edition 12.3 ©Silberschatz, Korth and Sudarshan
Use of Extendable Hash Structure
Database System Concepts - 6th Edition 12.4 ©Silberschatz, Korth and Sudarshan
Use of Extendable Hash Structure
Database System Concepts - 6th Edition 12.5 ©Silberschatz, Korth and Sudarshan
Insertion in Extendable Hash Structure
Splitting a bucket j when inserting record with search-key value K:
If i > ij (more than one pointer to bucket j)
Allocate a new bucket z, and set ij = iz = (ij + 1)
Update the second half of the bucket address table entries
originally pointing to j, to point to z
Remove each record in bucket j and reinsert (in j or z)
Recompute new bucket for K and insert record in the bucket
(further splitting is required if the bucket is still full)
If i = ij (only one pointer to bucket j)
If i reaches some limit b, or too many splits have happened in
this insertion, create an overflow bucket
Else
Increment i and double the size of the bucket address table.
Replace each entry in the table by two entries that point to the
same bucket.
Recompute new bucket address table entry for K
Now i > ij so use the first case above.
Database System Concepts - 6th Edition 12.6 ©Silberschatz, Korth and Sudarshan
Deletion in Extendable Hash Structure
Database System Concepts - 6th Edition 12.7 ©Silberschatz, Korth and Sudarshan
Use of Extendable Hash Structure: Example
Database System Concepts - 6th Edition 12.8 ©Silberschatz, Korth and Sudarshan
Example (Cont.)
Database System Concepts - 6th Edition 12.9 ©Silberschatz, Korth and Sudarshan
Example (Cont.)
Database System Concepts - 6th Edition 12.10 ©Silberschatz, Korth and Sudarshan
Use of Extendable Hash Structure: Example
Database System Concepts - 6th Edition 12.11 ©Silberschatz, Korth and Sudarshan
Example (Cont.)
Database System Concepts - 6th Edition 12.12 ©Silberschatz, Korth and Sudarshan
Example (Cont.)
Hash structure after insertion of Gold and El Said records
Database System Concepts - 6th Edition 12.13 ©Silberschatz, Korth and Sudarshan
Example (Cont.)
Hash structure after insertion of Katz record
Database System Concepts - 6th Edition 12.14 ©Silberschatz, Korth and Sudarshan
Example (Cont.)
Database System Concepts - 6th Edition 12.15 ©Silberschatz, Korth and Sudarshan
Use of Extendable Hash Structure: Example
Database System Concepts - 6th Edition 12.16 ©Silberschatz, Korth and Sudarshan
Example (Cont.)
Database System Concepts - 6th Edition 12.17 ©Silberschatz, Korth and Sudarshan
Extendable Hashing vs. Other Schemes
Benefits of extendable hashing:
Hash performance does not degrade with growth of file
Minimal space overhead
Disadvantages of extendable hashing
Extra level of indirection to find desired record
Bucket address table may itself become very big (larger than
memory)
Cannot allocate very large contiguous areas on disk either
Solution: B+-tree structure to locate desired record in bucket
address table
Changing size of bucket address table is an expensive
operation
Linear hashing is an alternative mechanism
Allows incremental growth of its directory (equivalent to bucket
address table)
At the cost of more bucket overflows
Database System Concepts - 6th Edition 12.18 ©Silberschatz, Korth and Sudarshan
End of Module 12a