








































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!









































This work, and all other files in this series, are licensed under the Creative Commons Attribution License. To view a copy of this license, visit http://creativecommons.org/licenses or send a letter to Creative Commons, 171 2nd Street, Suite 300, San Francisco, California, 94105, USA
These slides have benefited from the content of slides developed by Raghu Ramakrishnan, Johannes Gehrke, and Len Shapiro, whom I thank
Slides will be online by noon each Monday
Review Syllabus
Pre-requisite quiz
Personal Introductions What is your background in Databases? Any experience in DBMS aside from classes?
Minibase Intro, Buffer Manager assignment
Lecture on Chapter 8
Lecture on part of Chapter 9 needed for homework
Quit 10 minutes early to form teams What is your background in Java?
Learning Objectives for Chapter 8
Identify the input, output and function of each component in the architecture diagram
Be able to describe the relationships between different classifications of indexes Alternatives, clustering, uniqueness, denseness, primary
For each cell in the table on the “cost of operations” slide , explain the underlying algorithm and justify the cost.
Definitions: Index only plans, composite keys
Given a workload, choose an optimal index configuration.
Table of Contents: Chapter 8 (*review)
8.1 Data on external storage* Database architecture
8.2 File organizations and indexing* Indexes Alternatives for k* data entries Index classification: clustered, dense, unique, primary
8.3 Index search data structures* Hash-based indexes Tree indexes
8.4 Comparing File Organizations
8.5 Indexes and performance tuning*
What happens when an application reads a page from disk?
What else happens if the application writes the page?
16 9
22 41
62 15
2 11
2 9
11 15
16 22
41 62
16
9 41 2 22 62
11 15
Heap Sorted Hashed Bucket 0
1
2
3
Used by modern DBMSs
What are typical search structures in CS?
(Data file)
Data entries
Data Records
(Index File)^ k^ k^ k*
Search structure: given a key, it finds thedata entry for that key
Alternatives for Data Entry _k_* in Index
In a data entry k* we can store:
Choice of alternative for data entries is orthogonal to the indexing technique used to locate data entries with a given key value k. Examples of indexing techniques: B+ trees, hash-based structures Typically, index contains auxiliary information that directs searches to the desired data entries
8.Storage
10* 10* 21* 24* 30* 42*
10 Blue
42 Red
10 Green 30 Blue
21 Red 24 Blue INDEX
Alternative 3: 1 or more pointers per
k*
10* 18* 21* 24* 30*
10 Blue
18 Red
10 Green 30 Blue
21 Red 24 Blue INDEX
8.2.1 Clustered vs. Unclustered
Suppose that Alternative (2) is used for data entries, and that Index 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, order of data recs is `close to’, but not identical to, the sort order.)
Index entries
Data entries
direct search for
(Index File)
Data Records
CLUSTERED data entries
(Data file)
Data entries
Data Records
UNCLUSTERED
8.Storage
Primary vs. secondary : If search key contains primary key, then called primary index. In practice, primary means alternative 1
Unique index: Search key contains a candidate key.
Clustered vs. unclustered : If order of data records is the same as, or `close to’, order of data entries, then called clustered index. Alternative 1 implies clustered. A file can be clustered on at most one single-attributesearch key. Cost of retrieving data records through index varies greatly based on whether index is clustered or not!
8.Storage
Clustered, sparse indexes are smaller; they work well for range searches and sorting.
But…data blocks are difficult to keep sorted and some useful optimizations are based on dense indexes.
Note: one file can have at most one clustered index - all of the additional indices must be unclustered.
sparse dense
clustered YES YES
unclustered NO! YES
age h
Smith,44, Jones,40, Tracy,44,
Ashby,25, Basu,33, Bristow,29,
Cass,50, Daniels,22,
h(age)=
h(age)=
h(age)=
3000 3000 5004 5004
4003 2007 6003 6003
h sal
h(sal)=
h(sal)=
Employees file hashed on age Index on salary