Physical Design and Tuning Example

Slides:



Advertisements
Similar presentations
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Advertisements

Database Tuning. Overview v After ER design, schema refinement, and the definition of views, we have the conceptual and external schemas for our database.
Tuning in Relational Systems 2012/06/04. Index The performance of queries largely depends upon what indexes or hashing scheme exist. – Efficiency of queries.
6.830 Lecture 9 10/1/2014 Join Algorithms. Database Internals Outline Front End Admission Control Connection Management (sql) Parser (parse tree) Rewriter.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Physical Database Design Section Chapter 20.
Final Exam Coverage. E/R Converting E/R to Relations. SQL. –Joins and outerjoins –Subqueries –Aggregations –Views –Inserts, updates, deletes –Ordering.
Manajemen Basis Data Pertemuan 7 Matakuliah: M0264/Manajemen Basis Data Tahun: 2008.
Normalization DB Tuning CS186 Final Review Session.
Database Systems: A Practical Approach to Design, Implementation and Management International Computer Science S. Carolyn Begg, Thomas Connolly Lecture.
1 Physical Database Design and Tuning Module 5, Lecture 3.
Physical Database Monitoring and Tuning the Operational System.
Summary. Chapter 9 – Triggers Integrity constraints Enforcing IC with different techniques –Keys –Foreign keys –Attribute-based constraints –Schema-based.
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.
...Looking back Why use a DBMS? How to design a database? How to query a database? How does a DBMS work?
Chapter 8 Physical Database Design. McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Outline Overview of Physical Database.
Chapter 17 Methodology – Physical Database Design for Relational Databases Transparencies © Pearson Education Limited 1995, 2005.
Team Dosen UMN Physical DB Design Connolly Book Chapter 18.
Practical Database Design and Tuning. Outline  Practical Database Design and Tuning Physical Database Design in Relational Databases An Overview of Database.
Lecture 9 Methodology – Physical Database Design for Relational Databases.
Physical Database Design and Database Tuning, R. Ramakrishnan and J. Gehrke, modified by Ch. Eick 1 Physical Database Design Part II.
Physical Database Design Chapter 6. Physical Design and implementation 1.Translate global logical data model for target DBMS  1.1Design base relations.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Physical Database Design and Tuning.
Database Tuning Prerequisite Cluster Index B+Tree Indexing Hash Indexing ISAM (indexed Sequential access)
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.
1 CS 430 Database Theory Winter 2005 Lecture 16: Inside a DBMS.
Methodology – Physical Database Design for Relational Databases.
Indexes and Views Unit 7.
CMU SCS Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications C. Faloutsos – A. Pavlo Lecture#18: Physical Database Design.
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:
1 CSE444: REVIEW. 2 CSE444 in one slide v Logical : E/R diagram  normalized relations v Physical : files, buffering, and indexes v Logical : Relational.
Chapter 8 Physical Database Design. Outline Overview of Physical Database Design Inputs of Physical Database Design File Structures Query Optimization.
1 Overview of Query Evaluation Chapter Outline  Query Optimization Overview  Algorithm for Relational Operations.
What Should a DBMS Do? Store large amounts of data Process queries efficiently Allow multiple users to access the database concurrently and safely. Provide.
1 CS122A: Introduction to Data Management Lecture #15: Physical DB Design Instructor: Chen Li.
Databases and DBMSs Todd S. Bacastow January
Practical Database Design and Tuning
Indexes By Adrienne Watt.
CS 540 Database Management Systems
Database Design Dr. M.E. Fayad, Professor
Relational Database Design by Dr. S. Sridhar, Ph. D
Database Application Development
Methodology – Physical Database Design for Relational Databases
Physical Database Design for Relational Databases Step 3 – Step 8
Database Applications (15-415) DBMS Internals- Part III Lecture 15, March 11, 2018 Mohammad Hammoud.
Evaluation of Relational Operations: Other Operations
Examples of Physical Query Plan Alternatives
國立臺北科技大學 課程:資料庫系統 fall Chapter 18
Module 5: Overview of Normalization
Faloutsos/Pavlo C. Faloutsos – A. Pavlo Lecture#27: Final Review
Practical Database Design and Tuning
Transactions, Locking and Query Optimisation
Selected Topics: External Sorting, Join Algorithms, …
Index Use Cases.
What Should a DBMS Do? How will we do all this??
Final Review Topics Chapter 4 SQL,
Decomposition and Higher Forms of Normalization
SQL Tables and Constraints Example
Recommending Materialized Views and Indexes with the IBM DB2 Design Advisor (Automating Physical Database Design) Jarek Gryz.
Overview of Query Evaluation
Evaluation of Relational Operations: Other Techniques
CSE594: REVIEW.
Introduction to Execution Plans
Database Design Dr. M.E. Fayad, Professor
DBMS Physical Design Physical design is concerned with the placement of data and selection of access methods for efficiency and ongoing maintenance.
Introduction to Execution Plans
Evaluation of Relational Operations: Other Techniques
Physical Database Design
Chapter 7a: Overview of Database Design -- Normalization
Database Application Development
Physical Database Design and Tuning
Presentation transcript:

Physical Design and Tuning Example 1

The Database A hockey league with rinks, teams, and players: Rink (name, phone, capacity) Team (tname, city, color, wins, losses, tie, rname FK references Rink(name)) Player (id, name, num, pos, tname, tcity, FK (tname, tcity) references Team (tname, city)) All relations are in BCNF The only FDs are PKall other fields Constraint: All players with uniform number 9 must be goalies. 10

The Workload A mix of queries and updates: Q1 (20%): given player id, return num and pos Q2 (40%): given player position, return names, nums Q3 (5%): retrieve player name, num, pos, and rink Q4 (10%): get W-L-T record of a team (given name, city) Q5 (10%): produce an alphabetical team listing Q6 (5%): list all rink names from smallest to largest U1 (10%): update W-L-T information

Index Choices Q1: non-clustered index on player id Q2: clustered index on player pos Q3: index won’t help without harming Q2 Q4, Q5: clustered index on team (tname, city) Q6: clustered index on rink capacity U1: team (tname, city) index will help, as will lack of indices on wins, losses, tie attributes

Subsequent Tuning The system runs fine for a week, so you take a vacation. When you return…. General performance complaints abound you rebuild indices you create and update statistics you check optimizer plans Q3 is still particularly bad, and the league president wants it to be fast. you wisely decide to give him what he wants you denormalize to achieve a precomputed join

Denormalization Add rname field to player to avoid join: newplayer (id, name, num, pos, tname, tcity, rname FK references rink(rname), FK (tname, tcity) references team (tname, city)) newplayer is 2NF (YIKES!) DB is still lossless, dependency-preserving Must manage redundancy! Updates to newplayer (tname, tcity, rname) must check for correct value of rname Updates to team (rname) must propagate to newplayer Create a view to preserve external schema

Vertical Decomposition Suppose we want to speed up Q6. We can make it read fewer pages by decomposing: Rink_phone (name, phone), clust. index on name Rink_cap (name, capacity), clust. index on capacity Create a view to preserve external schema IC (FD) maintenance choices: leave it to user (scary!) allow inserts to “rink” view, not to base relations application pgm. to force user to enter both (atomic) insert into one base relation triggers insert into other

Unpreserved Dependencies Suppose the users now decide that all rinks in the same city have the same capacity: city  capacity While trying to remain calm, you realize that: This FD doesn’t exist in any single relation, so a join is required to check it each time we add or change a capacity value. The tradeoff: Expensive to check, but may not be checked often enough to justify creating a dependency-preserving decomposition.

Other SQL Server Tuning Has a general performance profiling tool Generates execution traces Queries can give optimizer hints: Use loop, hash, or merge join Use hash or sort to do grouping Force use of an index Force a join ordering Optimize for time-to-nth-result-tuple Adjust lock granularities and concurrency (next week…)

Summary Tunability varies among systems B trees nearly universal Denormalization, decomposition possible Storage structure size and growth tunable Optimizer hints common “Check” constraints very useful Triggers, assertions for IC (FD) enforcement