Chapter 8 – Part II. A glimpse at indices and workloads

Slides:



Advertisements
Similar presentations
Physical Database Design and Tuning R&G - Chapter 20 Although the whole of this life were said to be nothing but a dream and the physical world nothing.
Advertisements

Overview of Storage and Indexing
1 Overview of Indexing Chapter 8 – Part II. 1. Introduction to indexing 2. First glimpse at indices and workloads.
Overview of Storage and Indexing
Manajemen Basis Data Pertemuan 7 Matakuliah: M0264/Manajemen Basis Data Tahun: 2008.
1 Physical Design: Indexing Yanlei Diao UMass Amherst Feb 13, 2006 Slides Courtesy of R. Ramakrishnan and J. Gehrke.
DB performance tuning using indexes Section 8.5 and Chapters 20 (Raghu)
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Overview of Storage and Indexing Chapter 8 “How index-learning turns no student pale Yet.
File Organizations and Indexing Lecture 5 R&G Chapter 8 "If you don't find it in the index, look very carefully through the entire catalogue." -- Sears,
1 Physical Database Design and Tuning Module 5, Lecture 3.
1 File Organizations and Indexing Module 4, Lecture 2 “How index-learning turns no student pale Yet holds the eel of science by the tail.” -- Alexander.
Murali Mani Overview of Storage and Indexing (based on slides from Wisconsin)
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Overview of Storage and Indexing Chapter 8 “How index-learning turns no student pale Yet.
1 Overview of Indexing Chapter 8 – Part II. 1. Introduction to indexing 2. First glimpse at indices and workloads.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 File Organizations and Indexing Chapter 8.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Overview of Storage and Indexing Chapter 8.
Database Systems An Overview of Storage and Indexing
1 IT420: Database Management and Organization Storage and Indexing 14 April 2006 Adina Crăiniceanu
Physical Database Design and Database Tuning, R. Ramakrishnan and J. Gehrke, modified by Ch. Eick 1 Physical Database Design Part II.
Database Tuning Prerequisite Cluster Index B+Tree Indexing Hash Indexing ISAM (indexed Sequential access)
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Queries, Database Design, Constraint Enforcement Specify Schema + specify constraints.
Physical Database Design I, Ch. Eick 1 Physical Database Design I About 25% of Chapter 20 Simple queries:= no joins, no complex aggregate functions Focus.
Storage and Indexing1 Overview of Storage and Indexing.
1 Overview of Storage and Indexing Chapter 8 “How index-learning turns no student pale Yet holds the eel of science by the tail.” -- Alexander Pope ( )
DATABASE MANAGEMENT SYSTEMS TERM B. Tech II/IT II Semester UNIT-VIII PPT SLIDES Text Books: (1) DBMS by Raghu Ramakrishnan (2) DBMS by Sudarshan.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Overview of Storage and Indexing Chapter 8.
1 Overview of Storage and Indexing Chapter 8. 2 Data on External Storage  Disks: Can retrieve random page at fixed cost  But reading several consecutive.
Overview of Storage and Indexing Content based on Chapter 4 Database Management Systems, (Third Edition), by Raghu Ramakrishnan and Johannes Gehrke. McGraw.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Overview of Storage and Indexing Chapter 8 “How index-learning turns no student pale Yet.
1 Database Systems ( 資料庫系統 ) October 4, 2004 Lecture #4 By Hao-hua Chu ( 朱浩華 )
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Overview of Storage and Indexing Chapter 8 “If you don’t find it in the index, look very.
1 Database Systems ( 資料庫系統 ) October 29/31, 2007 Lecture #6.
Physical Database Design I, Ch. Eick 1 Physical Database Design I Chapter 16 Simple queries:= no joins, no complex aggregate functions Focus of this Lecture:
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Overview of Storage and Indexing Chapter 8.
Physical DB Design Jianlin Feng School of Software SUN YAT-SEN UNIVERSITY courtesy of Joe Hellerstein for some slides.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Overview of Storage and Indexing Chapter 8.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 File Organizations and Indexing Chapter 8 Jianping Fan Dept of Computer Science UNC-Charlotte.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Overview of Storage and Indexing Chapter 8.
1 Overview of Storage and Indexing Chapter 8. 2 Review: Architecture of a DBMS  A typical DBMS has a layered architecture.  The figure does not show.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Overview of Storage and Indexing Chapter 8 “If you don’t find it in the index, look very.
1 CS122A: Introduction to Data Management Lecture #15: Physical DB Design Instructor: Chen Li.
CS522 Advanced database Systems Huiping Guo Department of Computer Science California State University, Los Angeles 3. Overview of data storage and indexing.
Record Storage, File Organization, and Indexes
File Organization & Storage
Storage and Indexes Chapter 8 & 9
Examples of Physical Query Plan Alternatives
Lecture 12 Lecture 12: Indexing.
Hashing Chapter 11.
Introduction to Database Systems File Organization and Indexing
Overview of Storage and Indexing
CS222: Principles of Data Management Notes #09 Indexing Performance
File Organizations and Indexing
File Organizations and Indexing
B-Trees, Part 2 Hash-Based Indexes
Lecture 21: Indexes Monday, November 13, 2000.
Overview of Storage and Indexing
CS222P: Principles of Data Management Notes #09 Indexing Performance
Database Systems October 20, 2008 Lecture #6.
Overview of Storage and Indexing
File Storage and Indexing
Overview of Query Evaluation
Database Systems (資料庫系統)
Storage and Indexing.
Overview of Storage and Indexing
Physical Database Design and Tuning
Indexing February 28th, 2003 Lecture 20.
Overview of Storage and Indexing
Physical Database Design
CS222/CS122C: Principles of Data Management UCI, Fall 2018 Notes #08 Comparisons of Indexes and Indexing Performance Instructor: Chen Li.
Overview of Storage and Indexing
Presentation transcript:

Chapter 8 – Part II. A glimpse at indices and workloads Overview of Indexing Chapter 8 – Part II. A glimpse at indices and workloads The slides for this text are organized into chapters. This lecture covers Chapter 8, which introduces and compares several file and index organizations. This chapter has been completely rewritten in the 3rd edition of the book., with the goal of being a self-contained discussion of the central concepts of files, B trees, and hash indexes, and how to use them effectively in physical database design. It provides a quantitative comparison of the file storage and indexing alternatives, and how they support efficient evaluation of queries, including the concept of “index-only” evaluation plans. This chapter can be followed by a more in-depth discussion of B-trees, query evaluation, etc. Alternatively, it gives a concise overview of these topics from the perspective of a potential user, and can be used stand-alone in a course that emphasizes building applications over database system architecture. It covers the essential concepts in sufficient detail to support a discussion of physical database design and tuning in Chapter 20. 1

Understanding the Workload For each query in workload: Which relations does it access? Which attributes are retrieved? Which attributes are involved in selection/join conditions? How selective are these conditions likely to be? For each update in workload: The type of update (INSERT/DELETE/UPDATE), and the attributes that are affected. 11

Choice of Indexes What indexes should we create? Which relations should have indexes? What field(s) should be the search key? Should we build several indexes? For each index, what kind of an index should it be? Clustered vs. unclustered? Hash vs. tree? Clustering must be used sparingly and only when justified by frequent queries that benefit from clustering. At most one index can be clustered. Consider utilizing index-only evaluation. (e.g., avg(age)) 12

Choice of Indexes: One Approach Consider most important queries in turn. Consider best plan using current indexes, and see if a better plan possible with additional index. If so, create it. Consider impact on updates in workload! Trade-off: Indexes can make queries go faster, updates slower. Require disk space, too. 13

Choice of Indexes: Simple Approach For now, we discuss simple 1-table queries. 13

Index Selection Guidelines Attributes in WHERE clause are candidates for index keys. Exact match condition suggests hash index. Range query suggests tree index. Clustering is especially useful for range queries Clustering can also help equality queries if there are many duplicates. 14

Index Selection Guidelines Multi-attribute search keys considered when WHERE clause contains several conditions. Order of attributes is important for range queries. Such indexes can sometimes enable index-only strategies (Question : For index-only strategies, is clustering important ?) 14

Index Selection Guidelines Try to choose indexes that benefit as many queries as possible. Since only one index can be clustered per relation, choose it based on important queries that would benefit the most from clustering. 14

Examples of Clustered Indexes SELECT E.dno FROM Emp E WHERE E.age>40 B+ tree index on E.dno? B+ tree index on E.age ? Trade-offs : How selective is the condition? (all > 40?) or (only some > 40) Is the index clustered? 18

Examples of Clustered Indexes SELECT E.dno, COUNT (*) FROM Emp E WHERE E.age>10 GROUP BY E.dno Consider the GROUP BY query. Index on E.age ? E.dno ? Issues : Use Index on E.age ? If many tuples have E.age > 10, using E.age index and sorting the retrieved tuples may be costly. Use Index on E.dno ? Clustered E.dno index may be good here What about without WHERE condition? 18

Examples of Clustered Indexes SELECT E.dno FROM Emp E WHERE E.hobby=Stamps B+ tree index on E.hobby? NOTE: It is an equality query. NOTE : It may contain many duplicates. Clustered or Unclustered index ? CONCLUDE : Clustering on E.hobby helps! QUESTION: what if index is unclustered ? CONCLUDE: may prefer to do a full scan. 18

Indexes with Composite Search Keys Composite Search Keys: Search on combination of fields (sal and age). 11,80 11 12,10 12 name age sal 12,20 12 13,75 bob 12 10 13 <age, sal> cal 11 80 <age> joe 12 20 10,12 sue 13 75 10 20,12 Data records sorted by name 20 75,13 75 80,11 80 <sal, age> <sal> Data entries in index sorted by <sal,age> Data entries sorted by <sal> 13

Equality and Composite Search Keys Equality query Examples : age=20 sal =75 age=20 and sal =75 sal =75 and age=20 11,80 11 12,10 12 name age sal 12,20 12 13,75 bob 12 10 13 <age, sal> cal 11 80 <age> joe 12 20 10,12 sue 13 75 10 20,12 Data records sorted by name 20 75,13 75 80,11 80 <sal, age> <sal> Data entries in index sorted by <sal,age> Data entries sorted by <sal> 13

Composite Search Keys If retrieve Emp records with age=30 AND sal=4000 Index on <age,sal> would be better than an index on age or an index on sal. 20

Ranges and Composite Search Keys Examples of composite key indexes using lexicographic order. Range query: Some field value is not a constant but a range. Examples : age=12 and sal > 10 11,80 11 12,10 12 name age sal 12,20 12 13,75 bob 12 10 13 <age, sal> cal 11 80 <age> joe 12 20 10,12 sue 13 75 10 20,12 Data records sorted by name 20 75,13 75 80,11 80 <sal, age> <sal> Data entries in index sorted by <sal,age> Data entries sorted by <sal> 13

Composite Search Keys If condition is: 20<age<30 AND 3000<sal<5000: Clustered tree index on <age,sal> or <sal,age> is best. If condition is: age=30 AND 3000<sal<5000: Clustered <age,sal> index much better than <sal,age> index! Or, <age> is good choice. Composite indexes are larger, updated more often. 20

Index-Only Plans Answer a query without retrieving actual data tuples … Is that possible ? If index with suitable information is available. Why is it a good idea ? 21

Index-Only Plans + Does index-only evaluation make sense? SELECT E.dno, COUNT(*) FROM Emp E GROUP BY E.dno Tree index <E.dno> ? <E.dno> ? <E.sal> ? <E.dno,E.sal> ? SELECT E.dno, MIN(E.sal) FROM Emp E GROUP BY E.dno <E. age,E.sal> or <E.sal, E.age>? SELECT AVG(E.sal) FROM Emp E WHERE E.age=25 AND E.sal BETWEEN 3000 AND 5000 21

Index-Only Plans : Multi-Key Index PROS: + The chance for index-only evaluation is increased. CONS: - Index size larger. - Update response for any field. 21

Index-Only Plans Tree index on <dno,age>, or on : <age,dno> Which is better? SELECT E.dno, COUNT (*) FROM Emp E WHERE E.age=30 GROUP BY E.dno

Index-Only Plans Tree index on <dno,age>, or on : <age,dno> Which is better? SELECT E.dno, COUNT (*) FROM Emp E WHERE E.age=30 GROUP BY E.dno SELECT E.dno, COUNT (*) FROM Emp E WHERE E.age>30 GROUP BY E.dno What if we consider the second query?

Summary Understanding nature of workload for application, and the performance goals is essential to developing a good design. What are the important queries and updates? What attributes/relations are involved?

More Summary Indexes must be chosen to speed up important queries Index maintenance overhead on updates to key fields. Choose indexes that can help many queries, if possible. Build indexes to support index-only strategies. Clustering is an important decision; only one index on a given relation can be clustered Order of fields in composite index key can be important.