1 Revision and Exam Briefing M. Akhtar Ali School of CEIS.

Slides:



Advertisements
Similar presentations
Examples of Physical Query Plan Alternatives
Advertisements

CS 540 Database Management Systems
Evaluation of Relational Operators CS634 Lecture 11, Mar Slides based on “Database Management Systems” 3 rd ed, Ramakrishnan and Gehrke.
Advanced Databases: Lecture 2 Query Optimization (I) 1 Query Optimization (introduction to query processing) Advanced Databases By Dr. Akhtar Ali.
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.
Query Evaluation. SQL to ERA SQL queries are translated into extended relational algebra. Query evaluation plans are represented as trees of relational.
1 Chapter 10 Query Processing: The Basics. 2 External Sorting Sorting is used in implementing many relational operations Problem: –Relations are typically.
Lecture 24: Query Execution Monday, November 20, 2000.
CS263 Lecture 19 Query Optimisation.  Motivation for Query Optimisation  Phases of Query Processing  Query Trees  RA Transformation Rules  Heuristic.
1 Optimization Recap and examples. 2 Optimization introduction For every SQL expression, there are many possible ways of implementation. The different.
CSCI 5708: Query Processing I Pusheng Zhang University of Minnesota Feb 3, 2004.
1 Lecture 22: Query Execution Wednesday, March 2, 2005.
Quick Review of Apr 22 material Sections 13.1 through 13.3 in text Query Processing: take an SQL query and: –parse/translate it into an internal representation.
Query Optimization 3 Cost Estimation R&G, Chapters 12, 13, 14 Lecture 15.
CS186 Final Review Query Optimization.
CSCI 5708: Query Processing I Pusheng Zhang University of Minnesota Feb 3, 2004.
1 Query Processing: The Basics Chapter Topics How does DBMS compute the result of a SQL queries? The most often executed operations: –Sort –Projection,
Query Processing & Optimization
1 Relational Operators. 2 Outline Logical/physical operators Cost parameters and sorting One-pass algorithms Nested-loop joins Two-pass algorithms.
Query Optimization R&G, Chapter 15 Lecture 16. Administrivia Homework 3 available today –Written exercise; will be posted on class website –Due date:
ICOM 6005 – Database Management Systems Design Dr. Manuel Rodríguez-Martínez Electrical and Computer Engineering Department Lecture 14 – Join Processing.
1 Advanced Databases – CM036 Dr. Akhtar Ali School of Informatics.
Advanced Databases: Lecture 8 Query Optimization (III) 1 Query Optimization Advanced Databases By Dr. Akhtar Ali.
CPS216: Advanced Database Systems Notes 07:Query Execution Shivnath Babu.
CSC271 Database Systems Lecture # 12. Summary: Previous Lecture  Row selection using WHERE clause  WHERE clause and search conditions  Sorting results.
©Silberschatz, Korth and Sudarshan13.1Database System Concepts Chapter 13: Query Processing Overview Measures of Query Cost Selection Operation Sorting.
1 The module aims to: n Extend the concepts and practical implementation of the relational model. n Introduce the concepts of Object Oriented and Object-
Advanced Databases: Lecture 6 Query Optimization (I) 1 Introduction to query processing + Implementing Relational Algebra Advanced Databases By Dr. Akhtar.
Copyright © Curt Hill Query Evaluation Translating a query into action.
Computing & Information Sciences Kansas State University Tuesday, 03 Apr 2007CIS 560: Database System Concepts Lecture 29 of 42 Tuesday, 03 April 2007.
Query Execution Section 15.1 Shweta Athalye CS257: Database Systems ID: 118 Section 1.
Query Processing Bayu Adhi Tama, MTI. 1 ownerNoclient © Pearson Education Limited 1995, 2005.
Chapter 12 Query Processing (1) Yonsei University 2 nd Semester, 2013 Sanghyun Park.
CSCI Query Processing1 QUERY PROCESSING & OPTIMIZATION Dr. Awad Khalil Computer Science Department AUC.
CS 440 Database Management Systems Lecture 5: Query Processing 1.
1 Advanced Database Technologies CG096 Dr. Akhtar Ali School of Computing, Engineering and Information Systems Jan 2007.
Relational Operator Evaluation. overview Projection Two steps –Remove unwanted attributes –Eliminate any duplicate tuples The expensive part is removing.
CS 540 Database Management Systems
Query Execution Query compiler Execution engine Index/record mgr. Buffer manager Storage manager storage User/ Application Query update Query execution.
Chapter 10 The Basics of Query Processing. Copyright © 2005 Pearson Addison-Wesley. All rights reserved External Sorting Sorting is used in implementing.
CS4432: Database Systems II Query Processing- Part 1 1.
Database Applications (15-415) DBMS Internals- Part IX Lecture 20, March 31, 2016 Mohammad Hammoud.
CS 540 Database Management Systems
CS 440 Database Management Systems
Database Management System
Introduction to Query Optimization
Overview of Query Optimization
COST ESTIMATION FOR THE RELATIONAL ALGEBRA OPERATIONS MIT 813 GROUP 15 PRESENTATION.
Chapter 15 QUERY EXECUTION.
Database Management Systems (CS 564)
Introduction to Database Systems
Examples of Physical Query Plan Alternatives
Yan Huang - CSCI5330 Database Implementation – Access Methods
Query Processing B.Ramamurthy Chapter 12 11/27/2018 B.Ramamurthy.
Selected Topics: External Sorting, Join Algorithms, …
Database Applications (15-415) DBMS Internals- Part IX Lecture 21, April 1, 2018 Mohammad Hammoud.
Introduction to Database Systems CSE 444 Lecture 23: Final Review
Lecture 30: Final Review Wednesday, December 6, 2000.
Chapter 12 Query Processing (1)
Lecture 13: Query Execution
Relational Query Optimization
Lecture 23: Query Execution
Evaluation of Relational Operations: Other Techniques
Overview of Query Evaluation: JOINS
Lecture 30: Final Review Wednesday, December 10, 2003.
Lecture 22: Query Execution
Lecture 11: B+ Trees and Query Execution
Introduction to Database Systems CSE 444 Lecture 23: Final Review
Lecture 29: Final Review Wednesday, December 11, 2002.
Lecture 20: Query Execution
Presentation transcript:

1 Revision and Exam Briefing M. Akhtar Ali School of CEIS

Advanced Databases – Revision and Exam Briefing 2 Agenda Query optimization Object-relational and object-oriented databases

Advanced Databases – Revision and Exam Briefing 3 Query optimization SQL Query: SELECT C.fName, C.lName, P.street, P.city, P.rooms, P.rent FROM PropertyForRent P, Client C, Viewing V WHERE P.propertyNo = V.propertyNo ANDV.clientNo = C.clientNo AND V.viewDate = ‘10-JAN-2004’ ANDP.city = ‘Newcastle’ ANDP.type = ‘F’ ANDC.maxRent > 595

Advanced Databases – Revision and Exam Briefing 4 Query optimization … The Relational Algebra Query Tree

Advanced Databases – Revision and Exam Briefing 5 Query optimization: Information Assumed * The page size for the database is 2048 bytes. * The size of the PropertyForRent table is 5000 pages There are 90,000 records; Each record is of 112 bytes; 18 records occupy one page on disk; and log = 12 * The size the Client table is 4500 pages There are 103,500 records; Each record is of 88 bytes; 23 records occupy one page on disk; and log = 12 * The size the Viewing table is 5000 pages There are 145,000 records; Each record is of 70 bytes; 29 records occupy one page on disk; and log = 12

Advanced Databases – Revision and Exam Briefing 6 There are 5800 records in the Viewing table with viewDate = ‘10-JAN- 2004’. There are 31,500 records in the PropertyForRent table with type = ‘F’. There are 1800 records in the PropertyForRent table with city = ‘Newcastle’, however, only 900 of these properties are flats (i.e. with type = ‘F’). There are 20,700 records in the Client table with maxRent > 595. The result of the SQL query contains 2700 records and the size of each record is 146 bytes. The number of buffer pages available during query processing is 5 i.e. B = 5. Hash indexes (clustered) are available on city and type attributes of PropertyForRent table. B+ tree index (clustered) is available on maxRent attribute of Client table. The Viewing table is sorted in ascending order of viewDate. The join algorithms used by the DBMS for evaluating joins are: page- oriented nested and block-nested loops. Also note that you should consider the cost of writing to temporary tables for intermediate results. While calculating the evaluation cost of the query, ignore the cost of writing out the final result. Query optimization: Information Assumed

Advanced Databases – Revision and Exam Briefing 7 Apply logical query optimisation (i.e. transformation/re-writing rules and algebraic equivalence) to the relational algebra query tree and draw the logically optimised query tree thus obtained. Query optimization: Questions and Answers Initial Query TreeLogically Optimized Query Tree

Advanced Databases – Revision and Exam Briefing 8 Query optimization: Questions and Answers... Re-draw the query tree from part (a) and devise a physical plan for executing the relational operations involved in the tree.

Advanced Databases – Revision and Exam Briefing 9 Query optimization: Questions and Answers... Compute the cost for evaluating the physical plan in terms of I/O operations. The cost of Selection over PropertyForRent (using Hash Index on city attribute) Let H = 1, is the constant cost associated with Hash index to find out the RIDs (record identifiers) of the qualifying tuples. The number of qualifying tuples = 1800 The number of data pages read = 1800 / 18 = 100 The cost of this selection = H = 101 I/Os After reading each data page the condition type = ‘F’ is tested on each tuple. All tuples for which this condition is true are written to T1. The number of tuples in the result of 2 nd round of selection = 900 The cost of writing to T1 = 900 / 18 = 50 I/Os Subtotal cost = = 151 I/Os The size of temp T1 = 50 pages

Advanced Databases – Revision and Exam Briefing 10 Query optimization: Questions and Answers... The cost of Selection over Client (using B+ tree index on maxRent) Let BT = 2, the height of B+ tree index.The number of qualifying tuples = The number of pages read = / 23 = 900 Cost of selection = BT = 902 I/Os The cost of writing out the result to temp T2 = 900 I/Os. Subtotal cost = = 1802 I/Os The size of temp T2 = 900 pages

Advanced Databases – Revision and Exam Briefing 11 Query optimization: Questions and Answers... The cost of Selection over Client (using B+ tree index on maxRent) Let BT = 2, the height of B+ tree index.The number of qualifying tuples = The number of pages read = / 23 = 900 Cost of selection = BT = 902 I/Os The cost of writing out the result to temp T2 = 900 I/Os. Subtotal cost = = 1802 I/Os The size of temp T2 = 900 pages The cost of Selection over Viewing (using Binary search because the table is sorted on viewDate) Let VM = 5000 (the number of pages, the size of Viewing table) Let BS (be the average cost of using Binary Search) = log = log 5000 / log 2 = » 12 The number of qualifying tuples = 5800 The number of pages read = 5800 / 29 = 200 Cost of selection = BS = 212 I/Os The cost of writing out the result to temp T3 = 200 I/Os. Subtotal cost = = 412 I/Os The size of temp T3 = 200 pages

Advanced Databases – Revision and Exam Briefing 12 Query optimization: Questions and Answers... The cost of Join between T2 and T3 Given B = 5 (buffer pages) The Cost of Join = size of T3 + size of T2 * (size of T3 / B – 2) = * (200 / 3) = 60,200 I/Os. The size of the join result is computed as follows: The join will result in 5800 tuples, size of each tuple will be = 158 bytes Tuples per page = 2048 / 158 = 12, Size in pages = 484 The cost of writing to T4 = 484 I/Os Subtotal cost = = 60,684 I/Os. The cost of Join between T1 and T4 The Cost of Join = size of T1 + size of T4 * (size of T1 / B – 2) = * (50 / 3) = * 17 = 8278 I/Os. The overall cost = = 71,327 I/Os

Advanced Databases – Revision and Exam Briefing 13 OO Databases Questions like: Using ODL, provide an object-oriented representation of some classes/tables in the given UML class diagram / relational schema. Questions usually need a clear understanding of how to map / implement classes, attributes, associations and inheritance from UML onto the ODMG ODL or how to implement relations using OO database design and ODL. For this you should study past exam papers. Lecture material and seminars for weeks Compare and contrast object-oriented representations with relational equivalent. This should be specific to the question, and classes etc you have written in ODL and their equivalent relational counterpart given in the scenario. Answering a query in SQL and OQL and comparison and contrasting.

Advanced Databases – Revision and Exam Briefing 14 OR Databases Questions like: Using Oracle 9i, provide an object-relational representation of some classes in the given UML class diagram. Study past exam papers. Material covered on object-relational databases. Compare and contrast object-relational representations with relational equivalent. This should be specific to the question, and classes etc you have written in OR SQL and their equivalent relational counterpart given in the scenario. Answering a query OR SQL over the OR representations.