Hash-Based Indexes
In this lecture, you will delve into hash-based indexes, exploring their application in database management. Topics covered include static and dynamic hashing techniques, review of hashing structures, adjustments against inserts and deletes, extendible hashing, linear hashing, and the relative strengths of B+trees compared to hashing methods. Discover the primary characteristics and advantages of hash-based indexes for equality selections and learn about direct mapping tables and hash functions. Join the discussion on when to utilize hash-based indexes effectively within the context of database management.
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
Hash-Based Indexes Credits: Ramakrishnan & Gehrke Textbook to be published by Pearson Ed in early 2014 CSCIX370: Database Management http://www.funwebdev.com
What you will learn from this lecture Review of static hashing How to adjust hash structure dynamically against inserts and deletes? Extendible hashing Linear hashing Relative strengths of B+trees and Hashing: when to use what CSCIX370: Database Management
Introduction Hash-based indexes are best for equality selections no traversal; direct computation of where key should be cannot support range searches Static and dynamic hashing techniques exist; trade-offs similar to ISAM vs. B+ trees, on a certain level. CSCIX370: Database Management
Direct Mapping Table # primary/home buckets fixed, allocated sequentially, never de-allocated h(k) = k = bucket to which data entry with key k belongs. (M = # of buckets) #slots per bucket s, let s = 1 here 0 h(key) mod M 1 key h M-1 Primary bucket pages CSCIX370: Database Management
Direct Mapping Table Bucket private class Bucket { int nKeys = 0; // 0 or 1 Integer key = null; V value = null; Bucket next = null; V find (Integer k) { if (key != null && key.equals (k)) return value; return null; } // find void add (Integer k, V v) { nKeys = 1; key = k; value = v; } void print () { out.println ("[ " + key + " . ]" ); } } // Bucket inner class CSCIX370: Database Management
Direct Mapping Table Hash Function private int h (Object key) { return (int) key; } get Method @SuppressWarnings("unchecked") public V get (Object key) { var i = h (key); var bh = hTable.get (i); return bh.find ((Integer) key); } // get CSCIX370: Database Management
Static Hashing # primary/home buckets fixed, allocated sequentially, never de-allocated; overflow buckets if needed. h(k) mod M = bucket to which data entry with key k belongs. (M = # of buckets) 0 h(key) mod M 1 key h M-1 Primary bucket pages Overflow pages CSCIX370: Database Management
Static Hashing (Contd.) Buckets may contain data entries or references. Hash function works on search key field of record r. Must distribute values over range 0 ... M-1. h(key) = (key mod M) usually works well for prime M. lots known about how to tune h. Long overflow chains can develop and degrade performance (when there are updates). Extendible and Linear Hashing: two major dynamic techniques to fix this problem. CSCIX370: Database Management