Physical Database Design & Performance. Optimizing for Query Performance For DBs with high retrieval traffic as compared to maintenance traffic, optimizing.

Slides:



Advertisements
Similar presentations
Tuning Oracle SQL The Basics of Efficient SQLThe Basics of Efficient SQL Common Sense Indexing The Optimizer –Making SQL Efficient Finding Problem Queries.
Advertisements

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Tuning: overview Rewrite SQL (Leccotech)Leccotech Create Index Redefine Main memory structures (SGA in Oracle) Change the Block Size Materialized Views,
Database Performance Tuning and Query Optimization
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification.
Exadata Distinctives Brown Bag New features for tuning Oracle database applications.
Concepts of Database Management Seventh Edition
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.
The University of Akron Dept of Business Technology Computer Information Systems The Relational Model: Query-By-Example (QBE) 2440: 180 Database Concepts.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 11 Database Performance Tuning and Query Optimization.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 11 Database Performance Tuning and Query Optimization.
Evaluation of Relational Operations. Relational Operations v We will consider how to implement: – Selection ( ) Selects a subset of rows from relation.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Overview of Storage and Indexing Chapter 8.
Practical Database Design and Tuning. Outline  Practical Database Design and Tuning Physical Database Design in Relational Databases An Overview of Database.
Database Systems: Design, Implementation, and Management Tenth Edition Chapter 11 Database Performance Tuning and Query Optimization.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Database Performance Tuning and Query Optimization.
IT The Relational DBMS Section 06. Relational Database Theory Physical Database Design.
1 © Prentice Hall, 2002 Physical Database Design Dr. Bijoy Bordoloi.
1 IT420: Database Management and Organization Storage and Indexing 14 April 2006 Adina Crăiniceanu
CSE314 Database Systems More SQL: Complex Queries, Triggers, Views, and Schema Modification Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson.
1 Overview of Databases. 2 Content Databases Example: Access Structure Query language (SQL)
Oracle Database Administration Lecture 6 Indexes, Optimizer, Hints.
Data Warehousing 1 Lecture-24 Need for Speed: Parallelism Virtual University of Pakistan Ahsan Abdullah Assoc. Prof. & Head Center for Agro-Informatics.
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.
Relational Operator Evaluation. Overview Index Nested Loops Join If there is an index on the join column of one relation (say S), can make it the inner.
Using Special Operators (LIKE and IN)
Concepts of Database Management Seventh Edition
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.
1 Chapter 10 Joins and Subqueries. 2 Joins & Subqueries Joins – Methods to combine data from multiple tables – Optimizer information can be limited based.
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.
SQL/Lesson 7/Slide 1 of 32 Implementing Indexes Objectives In this lesson, you will learn to: * Create a clustered index * Create a nonclustered index.
Physical Database Design Purpose- translate the logical description of data into the technical specifications for storing and retrieving data Goal - create.
Partition Architecture Yeon JongHeum
Lec 7 Practical Database Design and Tuning Copyright © 2004 Pearson Education, Inc.
Relational Operator Evaluation. Overview Application Programmer (e.g., business analyst, Data architect) Sophisticated Application Programmer (e.g.,
Infrastructure for Data Warehouses. Basics Of Data Access Data Store Machine Memory Buffer Memory Cache Data Store Buffer Bus Structure.
Chapter 5 Index and Clustering
A Guide to SQL, Eighth Edition Chapter Five Multiple-Table Queries.
Query Optimization CMPE 226 Database Systems By, Arjun Gangisetty
CPSC 404, Laks V.S. Lakshmanan1 Evaluation of Relational Operations – Join Chapter 14 Ramakrishnan and Gehrke (Section 14.4)
Last Updated : 27 th April 2004 Center of Excellence Data Warehousing Group Teradata Performance Optimization.
IMS 4212: Database Implementation 1 Dr. Lawrence West, Management Dept., University of Central Florida Physical Database Implementation—Topics.
1 Chapter 9 Tuning Table Access. 2 Overview Improve performance of access to single table Explain access methods – Full Table Scan – Index – Partition-level.
Implementation of Database Systems, Jarek Gryz1 Evaluation of Relational Operations Chapter 12, Part A.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Overview of Storage and Indexing Chapter 8.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Evaluation of Relational Operations Chapter 14, Part A (Joins)
Database Systems, 8 th Edition SQL Performance Tuning Evaluated from client perspective –Most current relational DBMSs perform automatic query optimization.
Diving into Query Execution Plans ED POLLACK AUTOTASK CORPORATION DATABASE OPTIMIZATION ENGINEER.
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.
SQL IMPLEMENTATION & ADMINISTRATION Indexing & Views.
1 CS122A: Introduction to Data Management Lecture #15: Physical DB Design Instructor: Chen Li.
Practical Database Design and Tuning
Module 11: File Structure
Indexes By Adrienne Watt.
Physical Database Design
Physical Database Design and Performance
Database Performance Tuning &
Database Performance Tuning and Query Optimization
Evaluation of Relational Operations
Practical Database Design and Tuning
Selected Topics: External Sorting, Join Algorithms, …
The Physical Design Stage of SDLC (figures 2.4, 2.5 revisited)
Chapter 11 Database Performance Tuning and Query Optimization
CS222P: Principles of Data Management Notes #13 Set operations, Aggregation, Query Plans Instructor: Chen Li.
Evaluation of Relational Operations: Other Techniques
Virtual Memory 1 1.
Presentation transcript:

Physical Database Design & Performance

Optimizing for Query Performance For DBs with high retrieval traffic as compared to maintenance traffic, optimizing the DB for query performance is the primary goal. The amount of work required to do so greatly depends on the type of DBMS. Some DBMS give little control to DB designer / query writer on how a query is processed. Other give significant control to tune DB design and structure of queries.

Parallel Query Processing With the advent of multiple processors, many DB servers are now frequently using SMP technology. To exploit this parallel processing capability, some DBMS include strategies for breaking apart a query into modules that can be processed in parallel by each of the processors. A common approach is to replicate the query so that each copy works against a portion of the database (usually horizonally partitioned row sets). The same query runs in parallel on separate processors, intermediate results from each processor are combined to create final query result

Parallel Query Processing Parallel query processing speeds can be impressive (e.g., for a table scan, it can take half processing time as compared to normal processing) Other table operations that can make use of parallel processing: Table joins Grouping table results into categories Union operation Sorting rows Computing aggregate values Row update, delete and inserts Creating and rebuilding index

Overriding Automatic Query Optimization With most relational DBMSs, you can learn the optimizer’s plan for processing the query before it runs (EXPLAIN command). The query optimizer uses he best plan based on statistics about each table (no. of rows, avg row length, etc.) User must analyze the query costs before processing them. In Oracle, we may force a full scan as well as parallel scan in a query that counts total no. of orders (see example next slide).

Overriding Automatic Query Optimization Select /* + full(order) parallel(order,3)*/ count(*) from orders where salesperson=“Smith” The clause inside /* */ is a hint to Oracle to override the actual query plan. A hint is specific to each query.

Picking Block Size Data is transferred between RAM and disk memory in blocks or pages. Too small block size will increase I/O while too large one may result in extra data transfer. Usually min. block size is 2K bytes, typically max. size is 32 bytes or more (depends on OS) In general small block sizes are used for OLTP applications and larger sizes for DSS and data warehousing solutions

Picking Block Size (Contd.) Trade-offs among 5 performance factors while switching from small to large block sizes: Block contention In concurrent access of same block by several I/O commands, smaller blocks create less contention Random row access When one row from a table has to be accessed, smaller blocks are best, e.g., in case of OLTP applications Sequential row access When many rows have to be accessed sequentially, larger block size is better.

Picking Block Size (Contd.) Large blocks allow many rows to be cached in RAM in one I/O operation. Sequential scans occur in DSS and Datawarehousing application. Row size (length of all fields in a table row) It is usually best to match block size with physical table row size or a multiple of row size. Overhead This is the cost in terms of ‘time’ to manage I/O operations for a database operation. Smalle block sizes have more overhead than larger ones.

How to Design Better Queries? Various guidelines have been suggested by various DB experts for improving query processing. Understand how indexes are used in query processing Many DBMS use only 1 index per table in a query. Learn how DBMS selects which index. Drop infrequently used indexes. Queries using equality criteria process faster as they can be evaluated via indexes.

How to Design Better Queries? Use compatible data types for fields & literals in queries Compatible means DBMS will avoid to convert data during query processing. Write simple queries Simple queries are easy to process. Break complex queries into multiple, simple parts Result of smaller queries can be combined (using UNION) Don’t nest one query inside another Such queries are less efficient.

How to Design Better Queries? Don’t combine a table with itself Instead of self-join, make temp. copy of the table and then relate original with temp. table Create temporary tables for groups of queries Sometimes a series of queries all refer to same subset of data from database. it will be more efficient to store this subset in one or more temp. tables to avoid scanning DB again and again Combine update operations When possible, combine multiple update commands into one.

How to Design Better Queries? Receive only the data you need Reduce processing time by avoiding extra data columns which are not required (e.g. avoid use of select *) Don’t have the DBMS sort without an index Suppose data has to be displayed in sorted order and index does not exist on sort key field. Sort the data after it has been retrieved from DB Learn Review query plans using EXPLAIN command Understand ways in which DBMS determines query processing