Lecture11-Tree-Structured-Indexing

pdf

School

University of the Fraser Valley *

*We aren’t endorsed by this school

Course

13

Subject

Computer Science

Date

Oct 30, 2023

Type

pdf

Pages

30

Uploaded by kakger18

Report
SOEN 363 - Data Systems for Software Engineers Lecture 12: DBMS Internals- Part II Essam Mansour
Today… Last Session: DBMS Internals- Part I Buffer Management Files and Access Methods (file organizations) Today’s Session: DBMS Internals- Part II Tree-based indexes: ISAM and B+ trees
DBMS Layers Query Optimization and Execution Relational Operators Files and Access Methods Buffer Management Disk Space Management DB Queries Transaction Manager Lock Manager Recovery Manager
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Outline Why Indexing? Storing Data Records and Index Types Indexed Static Access Method (ISAM) Trees B+ Trees
Motivation Consider a file of student records sorted by GPA How can we answer a range selection ( E.g., “Find all students with a GPA higher than 3.0” )? What about doing a binary search followed by a scan ? Yes, but… What if the file becomes “very” large? Cost is proportional to the number of pages fetched Hence, may become very slow! Page 1 Page 2 Page N Page 3 Data File
Motivation What about creating an index file (with one entry per page) and do binary search there? But, what if the index file becomes also “very” large? Page 1 Page 2 Page N Data File Index File K 1 P 1 K 2 P 2 K N P N Index Entry = <first key on the page, pointer to the page>
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Motivation Repeat recursively! Non-leaf Pages Pages Leaf Each tree page is a disk block and all data records reside ( if chosen to be part of the index ) in ONLY leaf pages How else data records can be stored?
Outline Why Indexing? Storing Data Records and Index Types Indexed Static Access Method (ISAM) Trees B+ Trees
Where to Store Data Records? In general, 3 alternatives for “data records” (each referred to as K* ) can be pursued: Alternative (1): K* is an actual data record with key k Alternative (2): K* is a < k , rid> pair, where rid is the record id of a data record with search key k Alternative (3): K* is a < k , rid-list> pair, where rid-list is a list of rids of data records with search key k
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Where to Store Data Records? In general, 3 alternatives for “data records” (each referred to as K* ) can be pursued: Alternative (1): K* is an actual data record with key k Alternative (2): K* is a < k , rid> pair, where rid is the record id of a data record with search key k Alternative (3): K* is a < k , rid-list> pair, where rid-list is a list of rids of data records with search key k Alternative (1) : Leaf pages contain the actual data (i.e., the data records) Alternative (2) : Leaf pages contain the <key, rid> pairs and actual data records are stored in a separate file Alternative (3) : Leaf pages contain the <key, rid-list> pairs and actual data records are stored in a separate file The choice among these alternatives is orthogonal to the indexing technique
Clustered vs. Un-clustered Indexes Indexes can be either clustered or un-clustered Clustered Indexes: When the ordering of data records is the same as (or close to) the ordering of entries in some index Un-clustered Indexes: When the ordering of data records differs from the ordering of entries in some index
Clustered vs. Un-clustered Indexes Is an index that uses Alternative (1) clustered or un-clustered? Clustered Is an index that uses Alternative (2) or (3) clustered or un-clustered? Clustered “only” if data records are sorted on the search key field In practice: A clustered index is an index that uses Alternative (1) Indexes that use Alternatives (2) or (3) are un-clustered
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Clustered and Nonclustered Indexes
Clustered and Nonclustered Indexes CREATE INDEX myIndex ON SalesData (ProductID, OrderQty)
Clustered and Nonclustered Indexes CREATE INDEX myIndex ON SalesData (ProductID, OrderQty)
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Outline Why Indexing? Storing Data Records and Index Types Indexed Static Access Method (ISAM) Trees B+ Trees
ISAM Trees Indexed Sequential Access Method (ISAM) trees are static E.g., 2 Entries Per Page 10* 15* 20* 27* 33* 37* 40* 46* 51* 55* 63* 97* 20 33 51 63 40 Root Non-Leaf Pages Leaf Pages
ISAM Trees: Page Overflows What if there are a lot of insertions after creating the tree? Non-leaf Pages Pages Leaf Overflow page Primary pages
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
ISAM: Searching for Entries Search begins at root, and key comparisons direct it to a leaf Search for 27* 10* 15* 20* 27* 33* 37* 40* 46* 51* 55* 63* 97* 20 33 51 63 40 Root
ISAM: Inserting Entries The appropriate page is determined as for a search, and the entry is inserted (with overflow pages added if necessary) Insert 23* 10* 15* 20* 27* 33* 37* 40* 46* 51* 55* 63* 97* 20 33 51 63 40 Root 23*
ISAM: Inserting Entries The appropriate page is determined as for a search, and the entry is inserted (with overflow pages added if necessary) Insert 48* 10* 15* 20* 27* 33* 37* 40* 46* 51* 55* 63* 97* 20 33 51 63 40 Root 23* 48*
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
ISAM: Inserting Entries The appropriate page is determined as for a search, and the entry is inserted (with overflow pages added if necessary) Insert 41* 10* 15* 20* 27* 33* 37* 40* 46* 51* 55* 63* 97* 20 33 51 63 40 Root 23* 48* 41*
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
ISAM: Inserting Entries The appropriate page is determined as for a search, and the entry is inserted (with overflow pages added if necessary) Insert 42* 10* 15* 20* 27* 33* 37* 40* 46* 51* 55* 63* 97* 20 33 51 63 40 Root 23* 48* 41* 42* Chains of overflow pages can easily develop!
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
ISAM: Deleting Entries The appropriate page is determined as for a search, and the entry is deleted ( with ONLY overflow pages removed when becoming empty ) Delete 42* 10* 15* 20* 27* 33* 37* 40* 46* 51* 55* 63* 97* 20 33 51 63 40 Root 23* 48* 41* 42*
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
ISAM: Deleting Entries The appropriate page is determined as for a search, and the entry is deleted ( with ONLY overflow pages removed when becoming empty ) Delete 42* 10* 15* 20* 27* 33* 37* 40* 46* 51* 55* 63* 97* 20 33 51 63 40 Root 23* 48* 41*
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
ISAM: Deleting Entries The appropriate page is determined as for a search, and the entry is deleted ( with ONLY overflow pages removed when becoming empty ) Delete 42* 10* 15* 20* 27* 33* 37* 40* 46* 51* 55* 63* 97* 20 33 51 63 40 Root 23* 48* 41*
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
ISAM: Deleting Entries The appropriate page is determined as for a search, and the entry is deleted ( with ONLY overflow pages removed when becoming empty ) Delete 51* 10* 15* 20* 27* 33* 37* 40* 46* 51* 55* 63* 97* 20 33 51 63 40 Root 23* 48* 41* Note that 51 still appears in an index entry, but not in the leaf!
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
ISAM: Deleting Entries The appropriate page is determined as for a search, and the entry is deleted ( with ONLY overflow pages removed when becoming empty ) Delete 55* 10* 15* 20* 27* 33* 37* 40* 46* 55* 63* 97* 20 33 51 63 40 Root 23* 48* 41* Primary pages are NOT removed, even if they become empty!
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
ISAM: Some Issues Once an ISAM file is created, insertions and deletions affect only the contents of leaf pages (i.e., ISAM is a static structure !) Since index-level pages are never modified, there is no need to lock them during insertions/deletions Critical for concurrency! Long overflow chains can develop easily The tree can be initially set so that ~20% of each page is free If the data distribution and size are relatively static, ISAM might be a good choice to pursue!
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Next Lecture Why Indexing? Storing Data Records in Indexes and Index Types Indexed Static Access Method (ISAM) Trees B+ Trees
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help

Browse Popular Homework Q&A

Q: .
Q: The human assisted reproductive technologies can solve many problems.  What specific procedures can…
Q: Determine if the points (2, -3), (6,7), and (4,2) all lie on the same line. If so, find the equation…
Q: Why are bank failures considered to have a greater effect on the economy than other types of…
Q: What is the (unsigned) distance between the vertex and the focus of the parabola given by (x + 4)² =…
Q: Suppose an urn contains red, green, blue, and black marbles. Suppose you draw marbles from the urn 5…
Q: Use a calculator for this exercise.Chuong Ngo borrows $3000 from a bank that advertises a 7% simple…
Q: Please answer the ques with showing the code: (There is only 1 ques with 2 steps ) Q1: Step 1:…
Q: Given the following data, find the weight that represents the 60th percentile. 8.6 Weights of…
Q: a.) Infection with this pathogen can result in a wide range of diseases from ear infections to…
Q: For this discussion, you will post your initial response of at least 200 words, pose a thought…
Q: At The Container Store, part-time workers also get health benefits. Moreover, the company matches…
Q: The following thermochemical equation is for the reaction of Fe(s) with HCl(aq) to form FeCl2 (s)…
Q: A firm recorded it's ending inventory for the previous year at $40,000. It realized at the end of…
Q: 1000 grams of steel containing 1.5 weight percent carbon is heated to complete melting.  After…
Q: I need to graph the line y=mx+b for the given values
Q: A computer company produces affordable, easy-to-use home computer systems and has fixed costs of…
Q: What hybridization best describes the circled atom? O sp O sp³ O sp²
Q: The data below are the final scores of 10 randomly selected statistics students and the number of…
Q: How are you getting the graph on desmos? Like what equation are you putting in?
Q: Consider the following function. k(x) = 8x5 Step 2 of 2: Find two points on the graph of this…
Q: Show that the functions have exactly one zero inthe given interval. g(t) = 1/(1 - t) + √(1 + t )-…