Announcements. Reading Material. Recap. Today 9/17/17. Storage (contd. from Lecture 6)

Similar documents
Lecture 8 Index (B+-Tree and Hash)

Tree-Structured Indexes

Tree-Structured Indexes

Tree-Structured Indexes ISAM. Range Searches. Comments on ISAM. Example ISAM Tree. Introduction. As for any index, 3 alternatives for data entries k*:

Introduction. Choice orthogonal to indexing technique used to locate entries K.

Tree-Structured Indexes

Tree-Structured Indexes

Principles of Data Management. Lecture #5 (Tree-Based Index Structures)

Tree-Structured Indexes

Tree-Structured Indexes

Tree-Structured Indexes. Chapter 10

Tree-Structured Indexes

Tree-Structured Indexes. A Note of Caution. Range Searches ISAM. Example ISAM Tree. Introduction

Administrivia. Tree-Structured Indexes. Review. Today: B-Tree Indexes. A Note of Caution. Introduction

Spring 2017 B-TREES (LOOSELY BASED ON THE COW BOOK: CH. 10) 1/29/17 CS 564: Database Management Systems, Jignesh M. Patel 1

Introduction to Data Management. Lecture 15 (More About Indexing)

Indexing. Chapter 8, 10, 11. Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1

Lecture 13. Lecture 13: B+ Tree

Indexes. File Organizations and Indexing. First Question to Ask About Indexes. Index Breakdown. Alternatives for Data Entries (Contd.

Tree-Structured Indexes (Brass Tacks)

Storage and Indexing

Introduction to Indexing 2. Acknowledgements: Eamonn Keogh and Chotirat Ann Ratanamahatana

Introduction to Data Management. Lecture 21 (Indexing, cont.)

CSIT5300: Advanced Database Systems

THE B+ TREE INDEX. CS 564- Spring ACKs: Jignesh Patel, AnHai Doan

Goals for Today. CS 133: Databases. Example: Indexes. I/O Operation Cost. Reason about tradeoffs between clustered vs. unclustered tree indexes

Overview of Storage and Indexing

Kathleen Durant PhD Northeastern University CS Indexes

Principles of Data Management. Lecture #3 (Managing Files of Records)

Storing Data: Disks and Files. Storing and Retrieving Data. Why Not Store Everything in Main Memory? Chapter 7

Storing and Retrieving Data. Storing Data: Disks and Files. Solution 1: Techniques for making disks faster. Disks. Why Not Store Everything in Tapes?

Storing Data: Disks and Files. Storing and Retrieving Data. Why Not Store Everything in Main Memory? Database Management Systems need to:

CSE 444: Database Internals. Lectures 5-6 Indexing

L9: Storage Manager Physical Data Organization

Department of Computer Science University of Cyprus EPL446 Advanced Database Systems. Lecture 6. B+ Trees: Structure and Functions

Storing Data: Disks and Files

CompSci 516: Database Systems

Why Is This Important? Overview of Storage and Indexing. Components of a Disk. Data on External Storage. Accessing a Disk Page. Records on a Disk Page

CSC 261/461 Database Systems Lecture 17. Fall 2017

RAID in Practice, Overview of Indexing

Unit 3 Disk Scheduling, Records, Files, Metadata

Storing and Retrieving Data. Storing Data: Disks and Files. Solution 1: Techniques for making disks faster. Disks. Why Not Store Everything in Tapes?

Database Applications (15-415)

Announcements. Reading Material. Today. Different File Organizations. Selection of Indexes 9/24/17. CompSci 516: Database Systems

Disks and Files. Storage Structures Introduction Chapter 8 (3 rd edition) Why Not Store Everything in Main Memory?

CSE 544 Principles of Database Management Systems. Magdalena Balazinska Winter 2009 Lecture 6 - Storage and Indexing

Overview of Storage and Indexing

Storing Data: Disks and Files

Review 1-- Storing Data: Disks and Files

Storing Data: Disks and Files

CS220 Database Systems. File Organization

Data Management for Data Science

Overview of Storage and Indexing

Chapter 12: Indexing and Hashing (Cnt(

I think that I shall never see A billboard lovely as a tree. Perhaps unless the billboards fall I ll never see a tree at all.

Database System Concepts, 6 th Ed. Silberschatz, Korth and Sudarshan See for conditions on re-use

Chapter 12: Indexing and Hashing. Basic Concepts

Topics to Learn. Important concepts. Tree-based index. Hash-based index

Extra: B+ Trees. Motivations. Differences between BST and B+ 10/27/2017. CS1: Java Programming Colorado State University

Chapter 12: Indexing and Hashing

CSE 544 Principles of Database Management Systems

Storing Data: Disks and Files. Administrivia (part 2 of 2) Review. Disks, Memory, and Files. Disks and Files. Lecture 3 (R&G Chapter 7)

Disks and Files. Jim Gray s Storage Latency Analogy: How Far Away is the Data? Components of a Disk. Disks

Physical Disk Structure. Physical Data Organization and Indexing. Pages and Blocks. Access Path. I/O Time to Access a Page. Disks.

Storing Data: Disks and Files

Overview of Storage and Indexing

CS143: Index. Book Chapters: (4 th ) , (5 th ) , , 12.10

Overview of Storage and Indexing

Chapter 17. Disk Storage, Basic File Structures, and Hashing. Records. Blocking

Announcement. Reading Material. Overview of Query Evaluation. Overview of Query Evaluation. Overview of Query Evaluation 9/26/17

CS 405G: Introduction to Database Systems. Storage

User Perspective. Module III: System Perspective. Module III: Topics Covered. Module III Overview of Storage Structures, QP, and TM

Disks & Files. Yanlei Diao UMass Amherst. Slides Courtesy of R. Ramakrishnan and J. Gehrke

Database Systems. November 2, 2011 Lecture #7. topobo (mit)

Hash-Based Indexes. Chapter 11. Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1

Introduction to Data Management. Lecture 14 (Storage and Indexing)

INDEXES MICHAEL LIUT DEPARTMENT OF COMPUTING AND SOFTWARE MCMASTER UNIVERSITY

Indexing. Jan Chomicki University at Buffalo. Jan Chomicki () Indexing 1 / 25

Disks, Memories & Buffer Management

Chapter 11: Indexing and Hashing

Data Organization B trees

STORING DATA: DISK AND FILES

Chapter 11: Indexing and Hashing

Physical Level of Databases: B+-Trees

Project is due on March 11, 2003 Final Examination March 18, pm to 10.30pm

Database design and implementation CMPSCI 645. Lecture 08: Storage and Indexing

Chapter 11: Indexing and Hashing" Chapter 11: Indexing and Hashing"

Managing Storage: Above the Hardware

CSE 530A. B+ Trees. Washington University Fall 2013

Database Applications (15-415)

Chapter 12: Indexing and Hashing

Database Applications (15-415)

Chapter 11: Indexing and Hashing

CAS CS 460/660 Introduction to Database Systems. File Organization and Indexing

Overview of Storage and Indexing

Intro to DB CHAPTER 12 INDEXING & HASHING

Overview of Storage and Indexing. Data on External Storage

Selection Queries. to answer a selection query (ssn=10) needs to traverse a full path.

Data on External Storage

Material You Need to Know

Transcription:

CompSci 16 Intensive Computing Systems Lecture 7 Storage and Index Instructor: Sudeepa Roy Announcements HW1 deadline this week: Due on 09/21 (Thurs), 11: pm, no late days Project proposal deadline: Preliminary idea and team members due by tonight 09/18 (Mon), 11: pm by email to the instructor Proposal due on sakai by 09/2 (Mon), 11: pm Everyone should be in a group now otherwise let the instructor know asap Duke CS, Fall 20 CompSci 16: base Systems 1 Duke CS, Fall 20 CompSci 16: base Systems 2 Reading Material [RG] Storage: Chapters 8.1, 8.2, 8.4, 9.4-9.7 Index: 8.3, 8. Tree-based index: Chapter 10.1-10.7 Hash-based index: Chapter 11 Additional reading [GUW] Chapters 8.3, 14.1-14.4 Storage (contd. from Lecture 6) Acknowledgement: The following slides have been created adapting the instructor material of the [RG] book provided by the authors Dr. Ramakrishnan and Dr. Gehrke. Duke CS, Fall 20 CompSci 16: base Systems 3 Duke CS, Fall 20 CompSci 16: base Systems 4 Recap Today Typical DBMS hierarchy Disk and main memory/buffer pool Unit = page or block page replacement strategies dirty bit pin How are pages stored in a file? How are records stored in a page? Fixed length records Variable length records How are fields stored in a record? Fixed length fields/records Variable length fields/records Duke CS, Fall 20 CompSci 16: base Systems Duke CS, Fall 20 CompSci 16: base Systems 6 1

Files of Records File Organization or block is OK when doing I/O, but higher levels of DBMS operate on records, and files of records FILE: A collection of pages, each containing a collection of records Must support: insert/delete/modify record read a particular record (specified using record id) scan all records (possibly with some conditions on the records to be retrieved) File organization: Method of arranging a file of records on external storage One file can have multiple pages Record id (rid) is sufficient to physically locate the page containing the record on disk Indexes are data structures that allow us to find the record ids of records with given values in index search key fields NOTE: Several uses of keys in a database Primary/foreign/candidate/super keys Index search keys Duke CS, Fall 20 CompSci 16: base Systems 7 Duke CS, Fall 20 CompSci 16: base Systems 8 Alternative File Organizations Many alternatives exist, each ideal for some situations, and not so good in others: Heap (random order) files: Suitable when typical access is a file scan retrieving all records Sorted Files: Best if records must be retrieved in some order, or only a range of records is needed. Indexes: structures to organize records via trees or hashing Like sorted files, they speed up searches for a subset of records, based on values in certain ( search key ) fields Updates are much faster than in sorted files Unordered (Heap) Files Simplest file structure contains records in no particular order As file grows and shrinks, disk pages are allocated and de-allocated To support record level operations, we must: keep track of the pages in a file keep track of free space on pages keep track of the records on a page There are many alternatives for keeping track of this Duke CS, Fall 20 CompSci 16: base Systems 9 Duke CS, Fall 20 CompSci 16: base Systems 10 Heap File Implemented as a List Header Full s s with Free Space The header page id and Heap file name must be stored someplace Each page contains 2 `pointers plus data Problem? to insert a new record, we may need to scan several pages on the free list to find one with sufficient space Duke CS, Fall 20 CompSci 16: base Systems 11 Heap File Using a Directory Header DIRECTORY 1 2 N The entry for a page can include the number of free bytes on the page. The directory is a collection of pages linked list implementation of directory is just one alternative Much smaller than linked list of all heap file pages! Duke CS, Fall 20 CompSci 16: base Systems 12 2

How do we arrange a collection of records on a page? Each page contains several slots one for each record Record is identified by <page-id, slot-number> Fixed-Length Records Variable-Length Records Slot 1 Slot 2 Slot N Formats: Fixed Length Records...... PACKED N Free Space number of records Slot 1 Slot 2 Slot N Slot M 1... 0 1 M... 3 2 1 1 M UNPACKED, BITMAP number of slots For both, there are options for Record formats (how to organize the fields within a record) formats (how to organize the records within a page) Record id = <page id, slot #> Packed: moving records for free space management changes rid; may not be acceptable Unpacked: use a bitmap scan the bit array to find an empty slot Each page also may contain additional info like the id of the next page (not shown) Duke CS, Fall 20 CompSci 16: base Systems Duke CS, Fall 20 CompSci 16: base Systems 14 Formats: Variable Length Records Formats: Variable Length Records Need to find a page with the right amount of space Too small cannot insert Too large waste of space Rid = (i,n) Rid = (i,2) i if a record is deleted, need to move the records so that all free space is contiguous need ability to move records within a page Rid = (i,1) Can maintain a directory of slots (next slide) Slot contains <record-offset, record-length> deletion = set record-offset to -1 Record-id rid = <page, slot-in-directory> remains unchanged Duke CS, Fall 20 CompSci 16: base Systems 1 20 16 24 N N... 2 1 # slots SLOT DIRECTORY Can move records on page without changing rid so, attractive for fixed-length records too Store (record-offset, record-length) in each slot rid-s unaffected by rearranging records in a page Pointer to start of free space Duke CS, Fall 20 CompSci 16: base Systems 16 Record Formats: Fixed Length Base address (B) F1 F2 F3 F4 L1 L2 L3 L4 Address = B+L1+L2 Each field has a fixed length for all records the number of fields is also fixed fields can be stored consecutively Information about field types same for all records in a file stored in system catalogs Finding i-th field does not require scan of record given the address of the record, address of a field can be obtained easily Duke CS, Fall 20 CompSci 16: base Systems Record Formats: Variable Length Cannot use fixed-length slots for records Two alternative formats (# fields is fixed): F1 F2 F3 F4 Field Count 4 $ $ $ $ Fields Delimited by Special Symbols F1 F2 F3 F4 Array of Field Offsets 1. use delimiters 2. use offsets at the start of each record Second offers direct access to i-th field, efficient storage of nulls (special don t know value); small directory overhead Modification may be costly (may grow the field and not fit in the page) Duke CS, Fall 20 CompSci 16: base Systems 18 3

Indexes Indexes An index on a file speeds up selections on the search key fields for the index Any subset of the fields of a relation can be the search key for an index on the relation. Search key is not the same as key key = minimal set of fields that uniquely identify a tuple An index contains a collection of data entries, and supports efficient retrieval of all data entries k* with a given key value k Duke CS, Fall 20 CompSci 16: base Systems 19 Duke CS, Fall 20 CompSci 16: base Systems 20 Remember Terminology Alternatives for Entry k* in Index k Index search key (key): k Used to search a record entry : k* Pointed to by k Contains record id(s) or record itself Records or data Actual tuples Pointed to by record ids INDEX does this Duke CS, Fall 20 CompSci 16: base Systems 21 In a data entry k* we can store: 1. (Alternative 1) The actual data record with key value k, or 2. (Alternative 2) <k, rid> rid = record of data record with search key value k, or 3. (Alternative 3) <k, rid-list> list of record ids of data records with search key k> Choice of alternative for data entries is orthogonal to the indexing technique used to locate data entries with a given key value k Duke CS, Fall 20 CompSci 16: base Systems 22 Alternatives for Entries: Alternative 1 Alternatives for Entries: Alternative 2, 3 In a data entry k* we can store: 1. The actual data record with key value k 2. <k, rid> rid = record of data record with search key value k 3. <k, rid-list> Advantages/ Disadvantages? In a data entry k* we can store: 1. The actual data record with key value k 2. <k, rid> rid = record of data record with search key value k 3. <k, rid-list> Advantages/ Disadvantages? list of record ids of data records with search key k> list of record ids of data records with search key k> Index structure is a file organization for data records instead of a Heap file or sorted file How many different indexes can use Alternative 1? At most one index can use Alternative 1 Otherwise, data records are duplicated, leading to redundant storage and potential inconsistency If data records are very large, #pages with data entries is high Implies size of auxiliary information in the index is also large entries typically much smaller than data records So, better than Alternative 1 with large data records Especially if search keys are small. Alternative 3 more compact than Alternative 2 but leads to variable-size data entries even if search keys have fixed length. Duke CS, Fall 20 CompSci 16: base Systems 23 Duke CS, Fall 20 CompSci 16: base Systems 24 4

Index Classification Primary vs. Secondary Index Primary vs. secondary Clustered vs. unclustered Tree-based vs. Hash-based If search key contains primary key, then called primary index, otherwise secondary Unique index: Search key contains a candidate key Duplicate data entries: if they have the same value of search key field k Primary/unique index never has a duplicate Other secondary index can have duplicates Duke CS, Fall 20 CompSci 16: base Systems 2 Duke CS, Fall 20 CompSci 16: base Systems 26 Clustered vs. Unclustered Index If order of data records in a file is the same as, or `close to, order of data entries in an index, then clustered, otherwise unclustered Alternative 1 implies clustered Alternative 2, 3 are typically unclustered unless sorted according to the search key Sometimes, clustered also implies Alternative 1 since sorted files are rare A file can be clustered on at most one search key Cost of retrieving data records (range queries) through index varies greatly based on whether index is clustered or not Suppose that Alternative (2) is used for data entries, and that the data records are stored in a Heap file To build clustered index, first sort the Heap file with some free space on each page for future inserts Overflow pages may be needed for inserts Thus, data records are `close to, but not identical to, sorted CLUSTERED Clustered vs. Unclustered Index Index entries direct search for data entries entries (Index File) ( file) entries UNCLUSTERED Records Records Duke CS, Fall 20 CompSci 16: base Systems 27 Duke CS, Fall 20 CompSci 16: base Systems 28 Tree-based Hash-based (in detail later) Methods for indexing Duke CS, Fall 20 CompSci 16: base Systems 29 System Catalogs For each index: structure (e.g., B+ tree) and search key fields For each relation: name, file name, file structure (e.g., Heap file) attribute name and type, for each attribute index name, for each index integrity constraints For each view: view name and definition Plus statistics, authorization, buffer pool size, etc. (described in [RG] 12.1) Catalogs are themselves stored as relations! Duke CS, Fall 20 CompSci 16: base Systems

Range Searches Tree-based Index and B + -Tree ``Find all students with gpa > 3.0 If data is in sorted file, do binary search to find first such student, then scan to find others. Cost of binary search can be quite high. Duke CS, Fall 20 CompSci 16: base Systems 31 Duke CS, Fall 20 CompSci 16: base Systems 32 index entry Index file format P 0 K 1 P 1 K 2 P 2 K m P m Simple idea: Create an index file <first-key-on-page, pointer-to-page>, sorted on keys Indexed Sequential Access Method (ISAM) Leaf-pages contain data entry also some overflow pages DBMS organizes layout of the index a static structure If a number of inserts to the same leaf, a long overflow chain can be created affects the performance k1 k2 kn Index File Non-leaf s 1 2 3 N File Can do binary search on (smaller) index file but may still be expensive: apply this idea repeatedly Duke CS, Fall 20 CompSci 16: base Systems 33 Leaf s Overflow page Leaf pages contain data entries. Primary pages Duke CS, Fall 20 CompSci 16: base Systems 34 B+ Tree Most Widely Used Index a dynamic structure Insert/delete at log F N cost = height of the tree F = fanout, N = no. of leaf pages tree is maintained height-balanced Minimum 0% occupancy Each node contains d <= m <= 2d entries contains 1 <= m <= 2d entries The parameter d is called the order of the tree Supports equality and range-searches efficiently The index-file Index Entries (Direct search) Non-l eaf s Leaf s (Sorted by search key) B+ Tree Indexes Leaf pages contain data entries, and are chained (prev & next) Non-leaf pages have index entries; only used to direct searches: index entry P 0 K 1 P 1 K 2 P 2 K m P m Entries ("Sequence set") Duke CS, Fall 20 CompSci 16: base Systems 3 Duke CS, Fall 20 CompSci 16: base Systems 36 6

Example B+ Tree Search begins at root, and key comparisons direct it to a leaf Search for *, 1*, all data entries >= 24*... Based on the search for 1*, we know it is not in the tree! Example B+ Tree Entries <= Entries > 27 Note how data entries in leaf level are sorted 24 * 7* 8* 14* 16* 22* 24* 27* 29* 33* 34* 38* 39* * 7* 14* 16* 19* 20* 22* 24* 27* 29* 33* 34* 38* 39* Find 28*? 29*? All > 1* and < * Duke CS, Fall 20 CompSci 16: base Systems 37 Duke CS, Fall 20 CompSci 16: base Systems 38 B+ Trees in Practice Typical order: d = 100. Typical fill-factor: 67% average fanout F = 3 Typical capacities: Height 4: 3 4 = 312,900,700 records Height 3: 3 3 = 2,32,637 records Can often hold top levels in buffer pool: Level 1 = 1 page = 8 Kbytes Level 2 = 3 pages = 1 Mbyte Level 3 =,689 pages = 3 MBytes Inserting a 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. See this slide later, First, see examples on the next few slides 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. Duke CS, Fall 20 CompSci 16: base Systems 39 Duke CS, Fall 20 CompSci 16: base Systems 40 Inserting 8* into Example B+ Tree Inserting 8* into Example B+ Tree 24 STEP-1 Need to split parent 24 STEP-2 * 7* 14* 16* 19* 20* 22* 24* 27* 29* 33* 34* 38* 39* 14* 16* 19* 20* 22* 24* 27* 29* 33* 34* 38* 39* Copy-up: appears in leaf and the level above Observe how minimum occupancy is guaranteed * 7* 8* Entry to be inserted in parent node. (Note that iss copied up and continues to appear in the leaf.) Duke CS, Fall 20 CompSci 16: base Systems 41 * 7* 8* Note difference between copy-up and push-up What is the reason for this difference? All data entries must appear as leaves (for easy range search) no such requirement for indexes (so avoid redundancy) Entry to be inserted in parent node. (Note that is pushed up and only appears once in the index. Contrast this with a leaf split.) 24 7

Example B+ Tree After Inserting 8* * 7* 8* Notice that root was split, leading to increase in height. 24 14* 16* 19* 20* 22* 24* 27* 29* 33* 34* 38* 39* In this example, we can avoid split by re-distributing entries (insert 8 to the 2 nd leaf node from left and copy it up instead of ) however, this is usually not done in practice since need to access 1-2 extra pages always (for two siblings), and average occupancy may remain unaffected as the file grows Duke CS, Fall 20 CompSci 16: base Systems 43 Deleting a 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, Each non-root node contains d <= m <= 2d entries See this slide later, First, see examples on the next few slides 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 Duke CS, Fall 20 CompSci 16: base Systems 44 Example Tree: Delete 19* Example Tree: Delete 19* Before deleting 19* After deleting 19* 24 24 * 7* 8* 14* 16* 19* 20* 22* 24* 27* 29* 33* 34* 38* 39* * 7* 8* 14* 16* 20* 22* 24* 27* 29* 33* 34* 38* 39* We had inserted 8* Now delete 19* Easy Duke CS, Fall 20 CompSci 16: base Systems 4 Duke CS, Fall 20 CompSci 16: base Systems 46 Example Tree: Delete 20* Example Tree: Delete 20* Before deleting 20* After deleting 20* - step 1 24 24 * 7* 8* 14* 16* 20* 22* 24* 27* 29* 33* 34* 38* 39* * 7* 8* 14* 16* 22* 24* 27* 29* 33* 34* 38* 39* < 2 entries in leaf-node Redistribute Duke CS, Fall 20 CompSci 16: base Systems 47 Duke CS, Fall 20 CompSci 16: base Systems 48 8

Example Tree: Delete 20* Example Tree:... And Then Delete 24* After deleting 20* - step 2 Before deleting 24* 27 27 * 7* 8* 14* 16* 22* 24* 27* 29* 33* 34* 38* 39* * 7* 8* 14* 16* 22* 24* 27* 29* 33* 34* 38* 39* Notice how middle key is copied up Duke CS, Fall 20 CompSci 16: base Systems 49 Duke CS, Fall 20 CompSci 16: base Systems 0 Example Tree:... And Then Delete 24* Example Tree:... And Then Delete 24* After deleting 24* - Step 1 After deleting 24* - Step 2 Observe `toss of old index entry 27 27 * 7* 8* 14* 16* 22* 27* 29* 33* 34* 38* 39* * 7* 8* 14* 16* 22* 27* 29* 33* 34* 38* 39* Once again, imbalance at leaf Can we borrow from sibling(s)? No d-1 and d entries (d = 2) Need to merge Imbalance at parent Merge again But need to pull down root index entry because, three index,, but five pointers to leaves Duke CS, Fall 20 CompSci 16: base Systems 1 Duke CS, Fall 20 CompSci 16: base Systems 2 Final Example Tree Example of Non-leaf Re-distribution An intermediate tree is shown In contrast to previous example, can re-distribute entry from left child of root to right child * 7* 8* 14* 16* 22* 27* 29* 33* 34* 38* 39* 22 20 * 7* 8* 14* 16* * 18* 20* 21* 22* 27* 29* 33* 34* 38* 39* Duke CS, Fall 20 CompSci 16: base Systems 3 Duke CS, Fall 20 CompSci 16: base Systems 4 9

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 as well for illustration. * 7* 8* 20 22 14* 16* * 18* 20* 21* 22* 27* 29* 33* 34* 38* 39* Duplicates First Option: The basic search algorithm assumes that all entries with the same key value resides on the same leaf page If they do not fit, use overflow pages (like ISAM) Second Option: Several leaf pages can contain entries with a given key value Search for the left most entry with a key value, and follow the leaf-sequence pointers Need modification in the search algorithm if k* = <k, rid>, several entries have to be searched Or include rid in k becomes unique index, no duplicate If k* = <k, rid-list>, some solution, but if the list is long, again a single entry can span multiple pages Duke CS, Fall 20 CompSci 16: base Systems Duke CS, Fall 20 CompSci 16: base Systems 6 A Note on `Order Order (d) denotes minimum occupancy replaced by physical space criterion in practice (`at least halffull ) 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 (if we use Alternative (3)) Summary Tree-structured indexes are ideal for range-searches, also good for equality searches ISAM is a static structure Only leaf pages modified; overflow pages needed Overflow chains can degrade performance unless size of data set and data distribution stay constant B+ tree is a dynamic structure Inserts/deletes leave tree height-balanced; log F N cost High fanout (F) means depth rarely more than 3 or 4 Almost always better than maintaining a sorted file Most widely used index in database management systems because of its versatility. One of the most optimized components of a DBMS Next: Hash-based index Duke CS, Fall 20 CompSci 16: base Systems 7 Duke CS, Fall 20 CompSci 16: base Systems 8 10