Database Management COP4540, SCS, FIU Physical Database Design (2) (ch. 16 & ch. 6)

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

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
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: overview Rewrite SQL (Leccotech)Leccotech Create Index Redefine Main memory structures (SGA in Oracle) Change the Block Size Materialized Views,
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Copyright © 2011 Ramez Elmasri and Shamkant Navathe Algorithms for SELECT and JOIN Operations (8) Implementing the JOIN Operation: Join (EQUIJOIN, NATURAL.
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.
Relational Database. Relational database: a set of relations Relation: made up of 2 parts: − Schema : specifies the name of relations, plus name and type.
OUTLINE OF THE LECTURE PART I GOAL: Understand the Data Definition Statements in Fig 4.1 Step1: Columns of the Tables and Data types. Step2: Single column.
Query Evaluation. An SQL query and its RA equiv. Employees (sin INT, ename VARCHAR(20), rating INT, age REAL) Maintenances (sin INT, planeId INT, day.
Physical Database Design and Performance Dr. Mohamed Osman Ali Hegazi1.
Manajemen Basis Data Pertemuan 7 Matakuliah: M0264/Manajemen Basis Data Tahun: 2008.
DB performance tuning using indexes Section 8.5 and Chapters 20 (Raghu)
1 Physical Database Design and Tuning Module 5, Lecture 3.
Introduction to Structured Query Language (SQL)
© 2007 by Prentice Hall 1 Chapter 6: Physical Database Design and Performance Modern Database Management 8 th Edition Jeffrey A. Hoffer, Mary B. Prescott,
IS 4420 Database Fundamentals Chapter 6: Physical Database Design and Performance Leon Chen.
ACS-4902 Ron McFadyen Chapter 15 Algorithms for Query Processing and Optimization.
© 2005 by Prentice Hall 1 Chapter 6: Physical Database Design and Performance Modern Database Management 7 th Edition Jeffrey A. Hoffer, Mary B. Prescott,
ACS-4902 Ron McFadyen Chapter 15 Algorithms for Query Processing and Optimization See Sections 15.1, 2, 3, 7.
ICS (072)Query Processing and Optimization 1 Chapter 15 Algorithms for Query Processing and Optimization ICS 424 Advanced Database Systems Dr.
View Sen Zhang. Views are very common in business systems users view of data is simplified a form of security - user sees only the data he/she needs to.
Chapter 19 Query Processing and Optimization
Introduction to Structured Query Language (SQL)
CS346: Advanced Databases Graham Cormode Physical Database Design and Tuning.
© 2005 by Prentice Hall 1 Chapter 6: Physical Database Design and Performance Modern Database Management 7 th Edition Jeffrey A. Hoffer, Mary B. Prescott,
Chapter 6: Physical Database Design and Performance
Chapter 6 Physical Database Design. Introduction The purpose of physical database design is to translate the logical description of data into the technical.
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.
1 © Prentice Hall, 2002 Physical Database Design Dr. Bijoy Bordoloi.
MBA 664 Database Management Systems
Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Chapter 15-1 Query Processing and.
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management
Physical Database Design & Performance. Optimizing for Query Performance For DBs with high retrieval traffic as compared to maintenance traffic, optimizing.
TM 7-1 Copyright © 1999 Addison Wesley Longman, Inc. Physical Database Design.
Physical Database Design Chapter 6. Physical Design and implementation 1.Translate global logical data model for target DBMS  1.1Design base relations.
1 CS 430 Database Theory Winter 2005 Lecture 12: SQL DML - SELECT.
1 © Prentice Hall, 2002 Chapter 6: Physical Database Design and Performance Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B. Prescott,
Chapter 6 1 © Prentice Hall, 2002 The Physical Design Stage of SDLC (figures 2.4, 2.5 revisited) Project Identification and Selection Project Initiation.
Chapter 16 Practical Database Design and Tuning Copyright © 2004 Pearson Education, Inc.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
1 Agenda – 04/18/2006 and 04/20/2006 Identify tasks in physical database design. Define the design goals for physical database design. Discuss relevant.
Database Management COP4540, SCS, FIU Physical Database Design (ch. 16 & ch. 3)
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 7 Introduction to Structured Query Language (SQL)
Physical Database Design Purpose- translate the logical description of data into the technical specifications for storing and retrieving data Goal - create.
1 Agenda: 04/22 and 04/24 Answer questions about Replica Toys post-sales project. Total points remaining for the project = 140. Currently split into 30%
Lec 7 Practical Database Design and Tuning Copyright © 2004 Pearson Education, Inc.
Chapter 8 Physical Database Design. Outline Overview of Physical Database Design Inputs of Physical Database Design File Structures Query Optimization.
Advance Database Systems Query Optimization Ch 15 Department of Computer Science The University of Lahore.
Query Processing – Implementing Set Operations and Joins Chap. 19.
Query Optimization Cases. D. ChristozovINF 280 DB Systems Query Optimization: Cases 2 Executable Block 1 Algorithm using Indices (if available) Temporary.
Constraints and Views Chap. 3-5 continued (7 th ed. 5-7)
Database Systems, 8 th Edition SQL Performance Tuning Evaluated from client perspective –Most current relational DBMSs perform automatic query optimization.
Converting ER/EER to logical schema; physical design issues 1.
1 CS122A: Introduction to Data Management Lecture #15: Physical DB Design Instructor: Chen Li.
Practical Database Design and Tuning
Chapter # 14 Indexing Structures for Files
Indexing Structures for Files and Physical Database Design
Chapter 4 Basic SQL.
What is Database Administration
CHAPTER 5: PHYSICAL DATABASE DESIGN AND PERFORMANCE
Physical Database Design
Chapter 6: Physical Database Design and Performance
Practical Database Design and Tuning
Tuning Queries from (E&N)
The Physical Design Stage of SDLC (figures 2.4, 2.5 revisited)
ISC321 Database Systems I Chapter 4: SQL: Data definition, Constraints, and Basic Queries and Updates Fall 2015 Dr. Abdullah Almutairi.
Presentation transcript:

Database Management COP4540, SCS, FIU Physical Database Design (2) (ch. 16 & ch. 6)

Database Management COP4540, SCS, FIU Clustering Tables In some relational DBMSs, related records from different tables can be stored together in the same disk area. Data clustering in Oracle: CREATE CLUSTER ORDERING (CLUSTERKEY CHAR(25)); CREATE TABLE CUSTOMER ( CUSTOMER_IDVARCHAR(25) NOT NULL, CUSTOMER_ADDRESS VARCHAR(15) ) CLUSTER ORDERING (CUSTOMER_ID); CREATE TABLE ORDER ( ORDER_ID VARCHAR2(20) NOT NULL, CUSTOMER_ID VARCHAR2(25) NOT NULL ORDER_DATEDATE) CLUSTER ORDERING (CUSTOMER_ID);

Database Management COP4540, SCS, FIU Indexing Commands in Oracle CUSTOMER(CID, Name, Street, City, ST, ZIP) Primary Key Index: CREATE UNIQUE INDEX CUS_INX ON CUSTOMER (CID); Secondary Key Index: CREATE INDEX ZIP_INX ON CUSTOMER (ZIP); CREATE INDEX ST_INX ON CUSTOMER (ST); Bitmap Index: CREATE BITMAP INDEX CITY_INX ON CUSTOMER (CITY);

Database Management COP4540, SCS, FIU Rules for Using Indexes (1) Use on larger tables. Index the primary key of each table. Index search fields. Fields in ORDER BY and GROUP BY commands. When there are >100 values but not when there are <30 values.

Database Management COP4540, SCS, FIU Rules for Using Indexes (2) DBMS may have limit on number of indexes per table and number of bytes per indexed field(s). Null values will not be referenced from an index. Use indexes heavily for non-volatile databases; limit the use of indexes for volatile databases.

Database Management COP4540, SCS, FIU Rules for Adding Derived Columns Use when aggregate values are regularly retrieved and costly to calculate Do not permit updating to derived data Create triggers to cascade changes from source data.

Database Management COP4540, SCS, FIU Redundant Array of Inexpensive Disks (RAID) To improve file access performance by parallel processing of multiple disks Disk Striping: To distribute a sequence of data blocks horizontally on all disks so that the retrieval speed is increased There are several ways of striping the data and error correction codes on RAID, leading to RAID-0, -1, -2, -3, -4, and -5.

Database Management COP4540, SCS, FIU Tuning Queries Two indications that suggest that query tuning may be needed –A query issues too many disk accesses. –The query plan shows that relevant indexes are not being used

Database Management COP4540, SCS, FIU Tuning Guidelines (1) Many query optimizers do not use indexes in the presence of arithmetic expressions (such as salary/365 > 10.5), NULL comparisons (such as BDATE IS NULL), and substring comparisons (such as LNAME LIKE ‘%MANN’). Indexes are often not used for nested queries using IN. SELECT SSN FROM EMPLOYEE WHERE DNO IN (SELECT DNUMBER FROM DEPT WHERE MGRSSN = ‘ ’); SELECT SSN FROM EMPLOYEE, DEPT WHERE DNO = DNUMBER AND DEPT.MGRSSN = ‘ ’;

Database Management COP4540, SCS, FIU Tuning Guidelines (2) Some DISTINCT may be redundant and can be avoided without changing the result. SELECT DISTINCT SSN, NAME, ADDRESS FROM EMPLOYEE Avoid to use unnecessary temporary table. However, in some situation, temporaries are useful. SELECT SSN FROM EMPLOYEE AS E WHERE SALARY = ( SELECT MAX(SALARY) FROM EMPLOYEE AS M WHERE M.DNO = E.DNO); SELECT MAX(SALARY) AS HIGHSALARY, DNO INTO TEMP FROM EMPLOYEE GROUP BY DNO; SELECT SSN FROM EMPLOYEE, TEMP WHERE SALARY = HIGHSALARY AND EMPLOYEE.DNO = TEMP.DNO; DROP TABLE TEMP;

Database Management COP4540, SCS, FIU Tuning Guidelines (3) If multiple options for join condition are possible, choose the one that uses a clustering index and avoid that contain string comparison. Sometimes the order of the table in the from clause may affect the join processing. Some query optimizer perform worse on nested queries compared to their equivalent unnested counterparts. –Embedded SELECT blocks using IN, = ALL, and = SOME may be replaced by joins. Usually, it is good to transform NOT condition into a positive expression.

Database Management COP4540, SCS, FIU Tuning Guidelines (4) If an equality join is set up between two tables, the rang predicate on the joining attribute set up in one table may be repeated for the other table. Query optimizer may not use indexes on OR condition. SELECT FNAME, LNAME SALARY, AGE FROM EMPLOYEE WHERE AGE > 45 OR SALARY < 5000; SELECT FNAME, LNAME, SALARY, AGE FROM EMPLOYEE WHERE AGE > 45 OR SELECT FNAME, LNAME, SALARY, AGE FROM EMPLOYEE WHERE SALARY < 5000

Database Management COP4540, SCS, FIU Tuning Guidelines (4) WHERE conditions may be rewritten to utilize the indexes on multiple columns. SELECT RegionNo, Prod_type, Month, Sales FROM SALES_STATICS WHERE RegionNo = 3 AND ( (Prod_type BETWEEN 1 AND 3) OR (Prod_type BETWEEN 8 AND 10)); SELECT RegionNo, Prod_type, Month, Sales FROM SALES_STATICS WHERE RegionNo = 3 AND (Prod_type BETWEEN 1 AND 3) OR RegionNo = 3 AND (Prod_type BETWEEN 8 AND 10); Note: if there is a composite index defined on (RegionNo, Prod_type)