Lec 7 Practical Database Design and Tuning Copyright © 2004 Pearson Education, Inc.

Slides:



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

Tuning in Relational Systems 2012/06/04. Index The performance of queries largely depends upon what indexes or hashing scheme exist. – Efficiency of queries.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification.
Chapter 7 Indexing Structures for Files Copyright © 2004 Ramez Elmasri and Shamkant Navathe.
Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Chapter 15-1 Query Processing and.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 19 Algorithms for Query Processing and Optimization.
Chapter 15 Algorithms for Query Processing and Optimization Copyright © 2004 Pearson Education, Inc.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification.
Manajemen Basis Data Pertemuan 7 Matakuliah: M0264/Manajemen Basis Data Tahun: 2008.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 15 Basics of Functional Dependencies and Normalization for Relational.
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.
IS 4420 Database Fundamentals Chapter 6: Physical Database Design and Performance Leon Chen.
Physical Database Monitoring and Tuning the Operational System.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
Chapter 8 Physical Database Design. McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Outline Overview of Physical Database.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Overview of Database Languages and Architectures.
CS346: Advanced Databases Graham Cormode Physical Database Design and Tuning.
Chapter 8 Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
Chapter 17 Methodology – Physical Database Design for Relational Databases Transparencies © Pearson Education Limited 1995, 2005.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education 4-1.
Practical Database Design and Tuning. Outline  Practical Database Design and Tuning Physical Database Design in Relational Databases An Overview of Database.
CSC271 Database Systems Lecture # 30.
IT The Relational DBMS Section 06. Relational Database Theory Physical Database Design.
1 © Prentice Hall, 2002 Physical Database Design Dr. Bijoy Bordoloi.
Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Chapter 15-1 Query Processing and.
Lecture 9 Methodology – Physical Database Design for Relational Databases.
Software School of Hunan University Database Systems Design Part III Section 5 Design Methodology.
Physical Database Design & Performance. Optimizing for Query Performance For DBs with high retrieval traffic as compared to maintenance traffic, optimizing.
Physical Database Design Chapter 6. Physical Design and implementation 1.Translate global logical data model for target DBMS  1.1Design base relations.
Chapter 16 Methodology – Physical Database Design for Relational Databases.
Chapter 4 Functional Dependencies and Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
Chapter 6 1 © Prentice Hall, 2002 The Physical Design Stage of SDLC (figures 2.4, 2.5 revisited) Project Identification and Selection Project Initiation.
1 Index Structures. 2 Chapter : Objectives Types of Single-level Ordered Indexes Primary Indexes Clustering Indexes Secondary Indexes Multilevel Indexes.
Chapter 9 Disk Storage and Indexing Structures for Files Copyright © 2004 Pearson Education, Inc.
Chapter 16 Practical Database Design and Tuning Copyright © 2004 Pearson Education, Inc.
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.
© Pearson Education Limited, Chapter 13 Physical Database Design – Step 4 (Choose File Organizations and Indexes) Transparencies.
10/10/2012ISC239 Isabelle Bichindaritz1 Physical Database Design.
Physical Database Design Transparencies. ©Pearson Education 2009 Chapter 11 - Objectives Purpose of physical database design. How to map the logical database.
Chapter 13 Disk Storage, Basic File Structures, and Hashing. Copyright © 2004 Pearson Education, Inc.
Database Management COP4540, SCS, FIU Physical Database Design (2) (ch. 16 & ch. 6)
Methodology – Physical Database Design for Relational Databases.
In this session, you will learn to: Describe data redundancy Describe the first, second, and third normal forms Describe the Boyce-Codd Normal Form Appreciate.
University of Sunderland COM 220 Lecture Ten Slide 1 Database Performance.
Physical Database Design Purpose- translate the logical description of data into the technical specifications for storing and retrieving data Goal - create.
Chapter 8 Physical Database Design. Outline Overview of Physical Database Design Inputs of Physical Database Design File Structures Query Optimization.
Chapter 7 Functional Dependencies Copyright © 2004 Pearson Education, Inc.
Chapter 14 Indexing Structures for Files Copyright © 2004 Ramez Elmasri and Shamkant Navathe.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Lecture 4 Practical Database Design and Tuning.
Chapter 10 Functional Dependencies and Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
1 CS122A: Introduction to Data Management Lecture #15: Physical DB Design Instructor: Chen Li.
10/3/2017 Chapter 6 Index Structures.
Practical Database Design and Tuning
Indexing Structures for Files and Physical Database Design
Physical Database Design
Methodology – Physical Database Design for Relational Databases
Methodology – Monitoring and Tuning the Operational System
Physical Database Design for Relational Databases Step 3 – Step 8
Chapter 4 Relational Databases
Database Performance Tuning and Query Optimization
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Database System Concepts and Architecture.
CHAPTER 5: PHYSICAL DATABASE DESIGN AND PERFORMANCE
國立臺北科技大學 課程:資料庫系統 fall Chapter 18
Dynamic Hashing Good for database that grows and shrinks in size
Practical Database Design and Tuning
Tuning Queries from (E&N)
Methodology – Monitoring and Tuning the Operational System
Chapter 11 Database Performance Tuning and Query Optimization
Chapter 17 Designing Databases
Presentation transcript:

Lec 7 Practical Database Design and Tuning Copyright © 2004 Pearson Education, Inc.

Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Chapter 16-2 Chapter Outline 1. Physical Database Design in Relational Databases 2. An Overview of Database Tuning in Relational Systems.

Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Chapter Physical Database Design in Relational Databases Factors that Influence Physical Database Design: A.Analyzing the database queries and transactions For each query, the following information is needed. 1)The files that will be accessed by the query; 2)Whether the selection condition is an equality,inequality, or a range condition. 3)The attributes on which any join conditions or conditions to link multiple tables or objects for the query are specified; 4)The attributes whose values will be retrieved by the query.

Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Chapter 16-4 Factors that Influence Physical Database Design (cont.) A.Analyzing the database queries and transactions (cont.) For each update transaction or operation, the following information is needed. 1)The files that will be updated; 2)The type of operation on each file (insert, update or delete); 3)The attributes on which selection conditions for a delete or update operation are specified; 4)The attributes whose values will be changed by an update operation.

Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Chapter 16-5 Factors that Influence Physical Database Design (cont.) B.Analyzing the expected frequency of invocation of queries and transactions –The expected frequency information, along with the attribute information collected on each query and transaction, is used to compile a cumulative list of expected frequency of use for all the queries and transactions. –It is expressed as the expected frequency of using each attribute in each file as a selection attribute or join attribute, over all the queries and transactions.

Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Chapter 16-6 Factors that Influence Physical Database Design (cont.) C.Analyzing the time constraints of queries and transactions –Performance constraints place further priorities on the attributes that are candidates for access paths. –The selection attributes used by queries and transactions with time constraints become higher-priority candidates for primary access structure. D.Analyzing the expected frequencies of update operations A minimum number of access paths should be specified for a file that is updated frequently. E.Analyzing the uniqueness constraints on attributes. Access paths should be specified on all candidate key attributes — or set of attributes — that are either the primary key or constrained to be unique.

Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Chapter 16-7 Design decisions about indexing 1.Whether to index an attribute? 2.What attribute or attributes to index on? 3.Whether to set up a clustered index? 4.Whether to use a hash index over a tree index? 5.Whether to use dynamic hashing for the file? Physical Database Design Decisions

Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Chapter 16-8 Physical Database Design Decisions Denormalization as a design decision for speeding up queries –The goal of normalization is to separate the logically related attributes into tables to minimize redundancy and thereby avoid the update anomalies that cause an extra processing overhead to maintain consistency of the database. –The goal of denormalization is to improve the performance of frequently occurring queries and transactions. (Typically the designer adds to a table attributes that are needed for answering queries or producing reports so that a join with another table is avoided.)

Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Chapter An Overview of Database Tuning in Relational Systems Tuning: the process of continuing to revise/adjust the physical database design by monitoring resource utilization as well as internal DBMS processing to reveal bottlenecks such as contention for the same data or devices. Goal: –To make application run faster –To lower the response time of queries/transactions –To improve the overall throughput of transactions

Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Chapter Statistics internally collected in DBMSs: Size of individual tables Number of distinct values in a column The number of times a particular query or transaction is submitted/executed in an interval of time The times required for different phases of query and transaction processing Statistics obtained from monitoring: Storage statistics I/O and device performance statistics Query/transaction processing statistics Locking/logging related statistics Index statistics A brief overview of the tuning process

Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Chapter Problems to be considered in tuning: How to minimize overhead of logging and unnecessary dumping of data? How to optimize buffer size and scheduling of processes? How to allocate resources such as disks, RAM and processes for most efficient utilization?

Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Chapter Reasons to tuning indexes –Certain queries may take too long to run for lack of an index; –Certain indexes may not get utilized at all; –Certain indexes may be causing excessive overhead because the index is on an attribute that undergoes frequent changes Options to tuning indexes –Drop or/and build new indexes –Change a non-clustered index to a clustered index (and vice versa) –Rebuilding the index Tuning Indexes

Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Chapter Tuning the Database Design Dynamically changed processing requirements need to be addressed by making changes to the conceptual schema if necessary and to reflect those changes into the logical schema and physical design.

Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Chapter Tuning the Database Design (cont.) Possible changes to the database design –Existing tables may be joined (denormalized) because certain attributes from two or more tables are frequently needed together. –For the given set of tables, there may be alternative design choices, all of which achieve 3NF or BCNF. One may be replaced by the other. –A relation of the form R(K, A, B, C, D, …) that is in BCNF can be stored into multiple tables that are also in BCNF by replicating the key K in each table.this is called vertical partitioning –Attribute(s) from one table may be repeated in another even though this creates redundancy and potential anomalies. –Apply horizontal partitioning as well as vertical partitioning if necessary.

Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Chapter Tuning Queries Indications for tuning queries –A query issues too many disk accesses –The query plan shows that relevant indexes are not being used. Typical instances for query tuning 1.Many query optimizers do not use indexes in the presence of arithmetic expressions, numerical comparisons of attributes of different sizes and precision, NULL comparisons, and sub-string comparisons. 2.Indexes are often not used for nested queries using IN;

Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Chapter Tuning Queries (cont.) Typical instances for query tuning (cont.) 3.Some DISTINCTs may be redundant and can be avoided without changing the result. 4.Unnecessary use of temporary result tables can be avoided by collapsing multiple queries into a single query unless the temporary relation is needed for some intermediate processing. 5.In some situations involving using of correlated queries, temporaries are useful. 6.If multiple options for join condition are possible, choose one that uses a clustering index and avoid those that contain string comparisons.

Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Chapter Tuning Queries (cont.) Typical instances for query tuning (cont.) 7.The order of tables in the FROM clause may affect the join processing. 8.Many applications are based on views that define the data of interest to those applications. Sometimes these views become an overkill.

Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Chapter Additional Query Tuning Guidelines 1.A query with multiple selection conditions that are connected via OR may not be prompting the query optimizer to use any index. Such a query may be split up and expressed as a union of queries, each with a condition on an attribute that causes an index to be used. 2.Apply the following transformations –NOT condition may be transformed into a positive expression. –Embedded SELECT blocks may be replaced by joins. –If an equality join is set up between two tables, the range predicate on the joining attribute set up in one table may be repeated for the other table 3.WHERE conditions may be rewritten to utilize the indexes on multiple columns.