B+ Tree Index tuning--. overview B + -Tree Scalability Typical order: 100. Typical fill-factor: 67%. –average fanout = 133 Typical capacities (root at.

Slides:



Advertisements
Similar presentations
B+-Trees and Hashing Techniques for Storage and Index Structures
Advertisements

Database Management Systems, R. Ramakrishnan and J. Gehrke1 Tree-Structured Indexes Chapter 9.
1 Tree-Structured Indexes Module 4, Lecture 4. 2 Introduction As for any index, 3 alternatives for data entries k* : 1. Data record with key value k 2.
B+-trees. Model of Computation Data stored on disk(s) Minimum transfer unit: a page = b bytes or B records (or block) N records -> N/B = n pages I/O complexity:
Multilevel Indexing and B+ Trees
CS4432: Database Systems II
B+-tree and Hashing.
Tree-Structured Indexes Lecture 5 R & G Chapter 9 “If I had eight hours to chop down a tree, I'd spend six sharpening my ax.” Abraham Lincoln.
Tree-Structured Indexes Lecture 17 R & G Chapter 9 “If I had eight hours to chop down a tree, I'd spend six sharpening my ax.” Abraham Lincoln.
Tree-Structured Indexes. Introduction v As for any index, 3 alternatives for data entries k* : À Data record with key value k Á Â v Choice is orthogonal.
1 Tree-Structured Indexes Yanlei Diao UMass Amherst Feb 20, 2007 Slides Courtesy of R. Ramakrishnan and J. Gehrke.
FALL 2004CENG 351 File Structures1 Multilevel Indexing and B+ Trees Reference: Folk et al. Chapters: 9.1, 9.2, 10.1, 10.2,10.3,10.10.
1 Tree-Structured Indexes Chapter Introduction  As for any index, 3 alternatives for data entries k* :  Data record with key value k   Choice.
Indexing (cont.). Insertion in a B+ Tree Another B+ Tree
Tree-Structured Indexes Lecture 5 R & G Chapter 10 “If I had eight hours to chop down a tree, I'd spend six sharpening my ax.” Abraham Lincoln.
1 B+ Trees. 2 Tree-Structured Indices v Tree-structured indexing techniques support both range searches and equality searches. v ISAM : static structure;
CS4432: Database Systems II
B+ Review. B+ Tree: Most Widely Used Index Insert/delete at log F N cost; keep tree height- balanced. (F = fanout, N = # leaf pages) Minimum 50% occupancy.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 Tree-Structured Indexes Chapter 9.
Tree-Structured Indexes. Range Searches ``Find all students with gpa > 3.0’’ –If data is in sorted file, do binary search to find first such student,
Introduction to Database Systems1 B+-Trees Storage Technology: Topic 5.
 B+ Tree Definition  B+ Tree Properties  B+ Tree Searching  B+ Tree Insertion  B+ Tree Deletion.
Tree-Structured Indexes Lecture 5 R & G Chapter 10 “If I had eight hours to chop down a tree, I'd spend six sharpening my ax.” Abraham Lincoln.
Adapted from Mike Franklin
1.1 CS220 Database Systems Tree Based Indexing: B+-tree Slides courtesy G. Kollios Boston University via UC Berkeley.
Tree-Structured Indexes Jianlin Feng School of Software SUN YAT-SEN UNIVERSITY courtesy of Joe Hellerstein for some slides.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 Tree-Structured Indexes.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Tree- and Hash-Structured Indexes Selected Sections of Chapters 10 & 11.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 Tree-Structured Indexes Chapter 9.
1 Indexing. 2 Motivation Sells(bar,beer,price )Bars(bar,addr ) Joe’sBud2.50Joe’sMaple St. Joe’sMiller2.75Sue’sRiver Rd. Sue’sBud2.50 Sue’sCoors3.00 Query:
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 B+-Tree Index Chapter 10 Modified by Donghui Zhang Nov 9, 2005.
1 Database Systems ( 資料庫系統 ) November 1, 2004 Lecture #8 By Hao-hua Chu ( 朱浩華 )
Storage and Indexing. How do we store efficiently large amounts of data? The appropriate storage depends on what kind of accesses we expect to have to.
CPSC 404, Laks V.S. Lakshmanan1 Tree-Structured Indexes (Brass Tacks) Chapter 10 Ramakrishnan and Gehrke (Sections )
1 Tree-Structured Indexes Chapter Introduction  As for any index, 3 alternatives for data entries k* :  Data record with key value k   Choice.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Tree-Structured Indexes Content based on Chapter 10 Database Management Systems, (3 rd.
Tree-Structured Indexes Chapter 10
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Tree-Structured Indexes Chapter 10.
Tree-Structured Indexes R & G Chapter 10 “If I had eight hours to chop down a tree, I'd spend six sharpening my ax.” Abraham Lincoln.
Tree-Structured Indexes. Introduction As for any index, 3 alternatives for data entries k*: – Data record with key value k –  Choice is orthogonal to.
Multilevel Indexing and B+ Trees
Multilevel Indexing and B+ Trees
Database Systems (資料庫系統)
Tree-Structured Indexes
Tree-Structured Indexes
COP Introduction to Database Structures
Tree-Structured Indexes (Brass Tacks)
B+-Trees and Static Hashing
Tree-Structured Indexes
CS222/CS122C: Principles of Data Management Notes #07 B+ Trees
Introduction to Database Systems Tree Based Indexing: B+-tree
Tree-Structured Indexes
Tree-Structured Indexes
B+Trees The slides for this text are organized into chapters. This lecture covers Chapter 9. Chapter 1: Introduction to Database Systems Chapter 2: The.
Tree-Structured Indexes
Adapted from Mike Franklin
Tree-Structured Indexes
Indexing 1.
Database Systems (資料庫系統)
Storage and Indexing.
Database Systems (資料庫系統)
General External Merge Sort
Tree-Structured Indexes
Tree-Structured Indexes
Indexing February 28th, 2003 Lecture 20.
Tree-Structured Indexes
Tree-Structured Indexes
Tree-Structured Indexes
CS222/CS122C: Principles of Data Management UCI, Fall 2018 Notes #06 B+ trees Instructor: Chen Li.
CS222P: Principles of Data Management UCI, Fall Notes #06 B+ trees
Presentation transcript:

B+ Tree Index tuning--

overview

B + -Tree Scalability Typical order: 100. Typical fill-factor: 67%. –average fanout = 133 Typical capacities (root at Level 1, and has 133 entries): –Level 5: = 312,900,700 records –Level 4: = 2,352,637 records Can often hold top levels in buffer pool: –Level 1 = 1 page = 8 Kbytes –Level 2 = 133 pages = 1 Mbyte –Level 3 = 17,689 pages = 133 MBytes

A Note on `Order’ Order (d) concept replaced by physical space criterion in practice (`at least half-full’). –Index pages can typically hold many more entries than leaf pages. –Variable sized records and search keys mean different nodes will contain different numbers of entries. –Even with fixed length fields, multiple records with the same search key value (duplicates) can lead to variable-sized data entries

Inserting a Data Entry into a B+ Tree Find correct leaf L. Put data entry onto L. –If L has enough space, done! –Else, must split L (into L and a new node L2) Redistribute entries evenly, copy up middle key. Insert index entry pointing to L2 into parent of L. This can happen recursively –To split index node, redistribute entries evenly, but push up middle key. (Contrast with leaf splits.) Splits “grow” tree; root split increases height. –Tree growth: gets wider or one level taller at top.

Inserting 7 & 8 into Example B+ Tree Root (Note that 5 is copied up and continues to appear in the leaf.) Observe how minimum occupancy is guaranteed in both leaf and index pg splits.

Insertion (Cont) Note difference between copy-up and push-up; be sure you understand the reasons for this. appears once in the index. Contrast (Note that 17 is pushed up and only this with a leaf split.)

Example B+ Tree After Inserting 8 v Notice that root was split, leading to increase in height. v In this example, we can avoid splitting by re-distributing entries; however, this is usually not done in practice. Why? v checking whether redistribution is possible may increase I/Os 23 Root

Deleting a Data Entry from a B+ Tree Start at root, find leaf L where entry belongs. Remove the entry. –If L is at least half-full, done! –If L has only d-1 entries, Try to re-distribute, borrowing from sibling (adjacent node with same parent as L). If re-distribution fails, merge L and sibling. If merge occurred, must delete entry (pointing to L or sibling) from parent of L. Merge could propagate to root, decreasing height.

Example Tree After (Inserting 8, Then) Deleting 19 Deleting 19 is easy. 23 Root

Example Tree After Deleting Deleting 20 is done with re-distribution. Notice how middle key is copied up. 23 Root

... And Then Deleting 24 Must merge. Observe `toss’ of index entry (on right), and `pull down’ of index entry (below) Root

Example of Non-leaf Re-distribution (Delete 24) In contrast to previous example, can re- distribute entry from left child of root to right child. Root Root

After Re-distribution Intuitively, entries are re-distributed by `pushing through’ the splitting entry in the parent node. It suffices to re-distribute index entry with key 20; we’ve re-distributed 17 as well for illustration Root

B+tree deletions in practice –Often, mergeing/coalescing is not implemented –Too hard and not worth it!

Duplicates Using overflow page Several leaf pages may contain entries with the same key –To retrieve all data entries with a given key, we search for the left-most data entry with the key, then follow the leaf sequence pointers to find other pages.

B+-Tree Performance Tree levels –Tree Fanout Size of key Page utilization Tree maintenance –Online On inserts On deletes –Offline Tree locking Tree root in main memory

B+-Tree Performance Key length influences fanout –Choose small key when creating an index –Key compression Prefix compression (Oracle 8, MySQL): only store that part of the key that is needed to distinguish it from its neighbors: Smi, Smo, Smy for Smith, Smoot, Smythe. Front compression (Oracle 5): adjacent keys have their front portion factored out: Smi, (2)o, (2)y. There are problems with this approach: –Processor overhead for maintenance –Locking Smoot requires locking Smith too.

Prefix Key Compression Key values in index entries only `direct traffic’; can often compress them. E.g., If we have adjacent index entries with search key values Dannon Yogurt, David Smith and Devarakonda Murthy, we can abbreviate David Smith to Dav. (The other keys can be compressed too...) – Is this correct? Not quite! What if there is a data entry Davey Jones? (Can only compress David Smith to Davi) –In general, while compressing, must leave each index entry greater than every key value (in any subtree) to its left. Insert/delete must be suitably modified.

summarize