Session11

Session11 - Chapter 12: Indexing and Hashing (Cnt.) Basic...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Chapter 12: Indexing and Hashing ( Chapter 12: Indexing and Hashing ( Cnt Cnt .) .) x Basic Concepts x Ordered Indices x B+-Tree Index Files x B-Tree Index Files x Static Hashing x Dynamic Hashing x Comparison of Ordered Indexing and Hashing x Index Definition in SQL x Multiple-Key Access
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 2 Queries on B Queries on B + + - - Trees Trees x Find all records with a search-key value of k. 1. Start with the root node 1. Examine the node for the smallest search-key value > k. 2. If such a value exists, assume it is K j . Then follow P j to the child node 3. Otherwise k K m –1 , where there are m pointers in the node. Then follow P m to the child node. 2. If the node reached by following the pointer above is not a leaf node, repeat the above procedure on the node, and follow the corresponding pointer. 3. Eventually reach a leaf node. If for some i , key K i = k follow pointer P i to the desired record or bucket. Else no record with search-key value k exists.
Background image of page 2
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 3 Queries on B Queries on B + + - - Trees (Cont.) Trees (Cont.) x In processing a query, a path is traversed in the tree from the root to some leaf node. x If there are K search-key values in the file, the path is no longer than log n /2 ( K ) . x A node is generally the same size as a disk block, typically 4 kilobytes, and n is typically around 100 (40 bytes per index entry). x With 1 million search key values and n = 100, at most log 50 (1,000,000) = 4 nodes are accessed in a lookup. x Contrast this with a balanced binary tree with 1 million search key values — around 20 nodes are accessed in a lookup s above difference is significant since every node access may need a disk I/O, costing around 20 milliseconds!
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 4 Updates on B Updates on B + + - - Trees: Insertion Trees: Insertion x Find the leaf node in which the search-key value would appear x If the search-key value is already there in the leaf node, record is added to file and if necessary a pointer is inserted into the bucket. x If the search-key value is not there, then add the record to the main file and create a bucket if necessary. Then: s If there is room in the leaf node, insert (key-value, pointer) pair in the leaf node s Otherwise, split the node (along with the new (key-value, pointer) entry) as discussed in the next slide.
Background image of page 4
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 5 Updates on B Updates on B + + - - Trees: Insertion (Cont.) Trees: Insertion (Cont.) x Splitting a node: s take the n (search-key value, pointer) pairs (including the one being inserted) in sorted order. Place the first n /2 in the original node, and the rest in a new node. s
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 05/16/2010.

Page1 / 25

Session11 - Chapter 12: Indexing and Hashing (Cnt.) Basic...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online