Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See www.db-book.com for conditions on re-usewww.db-book.com Chapter 13: Query Processing.

Slides:



Advertisements
Similar presentations
Chapter 13: Query Processing
Advertisements

Chapter 12: Query Processing
SPRING 2004CENG 3521 Query Evaluation Chapters 12, 14.
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Query Processing.
©Silberschatz, Korth and Sudarshan13.1Database System Concepts Chapter 13: Query Processing Overview Measures of Query Cost Selection Operation Sorting.
Query Processing (overview)
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 13: Query Processing.
CSCI 5708: Query Processing I Pusheng Zhang University of Minnesota Feb 3, 2004.
Database System Concepts 5 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 14: Query Optimization.
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 11: Storage and.
CSCI 5708: Query Processing I Pusheng Zhang University of Minnesota Feb 3, 2004.
Bitmap Indexes.
©Silberschatz, Korth and Sudarshan14.1Database System Concepts 3 rd Edition Chapter 14: Query Optimization Overview Catalog Information for Cost Estimation.
©Silberschatz, Korth and Sudarshan13.1Database System Concepts Chapter 13: Query Processing Overview Measures of Query Cost Selection Operation Sorting.
Dr. Kalpakis CMSC 461, Database Management Systems Query Processing.
1 Chapter 13 CS 157 B Presentation -- Query Processing (origional from Silberschatz, Korth and Sudarshan) Presented By Laptak Lee.
©Silberschatz, Korth and Sudarshan12.1Database System Concepts B + -Tree Index Files Indexing mechanisms used to speed up access to desired data.  E.g.,
Query Processing Chapter 12
COMP 5138 Relational Database Management Systems Semester 2, 2007 Lecture 12 Query Processing and Optimization.
©Silberschatz, Korth and Sudarshan13.1Database System Concepts Chapter 13: Query Processing Overview Measures of Query Cost Selection Operation Sorting.
Chapter 13 Query Processing Melissa Jamili CS 157B November 11, 2004.
©Silberschatz, Korth and Sudarshan7.1 Chapter 13: Query Processing Overview Measures of Query Cost Selection Operation Sorting Join Operation Other Operations.
Query Processing. Steps in Query Processing Validate and translate the query –Good syntax. –All referenced relations exist. –Translate the SQL to relational.
©Silberschatz, Korth and Sudarshan14.1Database System Concepts 3 rd Edition Chapter 14: Query Optimization Overview Catalog Information for Cost Estimation.
12.1Database System Concepts - 6 th Edition Chapter 12: Query Processing Overview Measures of Query Cost Selection Operation Join Operation Sorting 、 Other.
SCUHolliday - COEN 17814–1 Schedule Today: u Query Processing overview.
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan Chapter 13: Query Processing.
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 13: Query Processing.
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 13: Query Processing.
Chapter 13: Query Processing Chapter 13: Query Processing Overview Measures of Query Cost Selection Operation Sorting Join Operation Other Operations.
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chap 13 Query Processing.
Computing & Information Sciences Kansas State University Tuesday, 03 Apr 2007CIS 560: Database System Concepts Lecture 29 of 42 Tuesday, 03 April 2007.
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 13: Query Processing.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 12: Query Processing.
Lecture 1- Query Processing Advanced Databases Masood Niazi Torshiz Islamic Azad university- Mashhad Branch
CPT-S Topics in Computer Science Big Data 1 1 Yinghui Wu EME 49.
Chapter 12 Query Processing. Query Processing n Selection Operation n Sorting n Join Operation n Other Operations n Evaluation of Expressions 2.
Chapter 12 Query Processing (1) Yonsei University 2 nd Semester, 2013 Sanghyun Park.
Chapter 13: Query Processing
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 13: Query Processing.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Indexing.
QUERY PROCESSING RELATIONAL DATABASE KUSUMA AYU LAKSITOWENING
Computing & Information Sciences Kansas State University Monday, 03 Nov 2008CIS 560: Database System Concepts Lecture 27 of 42 Monday, 03 November 2008.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 12: Query Processing.
Computing & Information Sciences Kansas State University Wednesday, 08 Nov 2006CIS 560: Database System Concepts Lecture 32 of 42 Monday, 06 November 2006.
13.1 Chapter 13: Query Processing n Overview n Measures of Query Cost n Selection Operation n Sorting n Join Operation n Other Operations n Evaluation.
Chapter 13: Query Processing. Overview Measures of Query Cost Selection Operation Sorting Join Operation Other Operations Evaluation of Expressions.
File Processing : Query Processing 2008, Spring Pusan National University Ki-Joune Li.
©Silberschatz, Korth and Sudarshan1 Query Processing Overview Measures of Query Cost Selection Operation Sorting Join Operation Other Operations Evaluation.
Query Processing and Query Optimization Database System Implementation CSE 507 Some slides adapted from Silberschatz, Korth and Sudarshan Database System.
Computing & Information Sciences Kansas State University Wednesday, 02 Apr 2008CIS 560: Database System Concepts Lecture 27 of 42 Wednesday, 02 April 2008.
Query Processing and Optimization Muheet Ahmed Butt.
Chapter 13: Query Processing
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 12: Query Processing.
Query Processing  Basic Steps in Query Processing – an overview  Measures of Query Cost  Query Processing- Several algorithms  Selection Operation.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 12: Query Processing.
Chapter 4: Query Processing
Database Management System
Chapter 13: Query Processing
Chapter 12: Query Processing
Chapter 12: Query Processing
Chapter 13: Query Processing
File Processing : Query Processing
Dynamic Hashing Good for database that grows and shrinks in size
Query Processing B.Ramamurthy Chapter 12 11/27/2018 B.Ramamurthy.
Query Processing.
Module 13: Query Processing
Chapter 12 Query Processing (1)
Chapter 13: Query Processing
Query Processing.
Presentation transcript:

Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 13: Query Processing

©Silberschatz, Korth and Sudarshan13.2Database System Concepts - 5 th Edition, Aug 27, Basic Steps in Query Processing 1.Parsing and translation 2.Optimization 3.Evaluation

©Silberschatz, Korth and Sudarshan13.3Database System Concepts - 5 th Edition, Aug 27, Basic Steps in Query Processing (Cont.) n Parsing and translation l translate the query into its internal form. This is then translated into relational algebra. l Parser checks syntax, verifies relations n Evaluation l The query-execution engine takes a query-evaluation plan, executes that plan, and returns the answers to the query.

©Silberschatz, Korth and Sudarshan13.4Database System Concepts - 5 th Edition, Aug 27, Basic Steps in Query Processing : Optimization n A relational algebra expression may have many equivalent expressions l E.g.,  balance  2500 (  balance (account)) is equivalent to  balance (  balance  2500 (account)) n Each relational algebra operation can be evaluated using one of several different algorithms l Correspondingly, a relational-algebra expression can be evaluated in many ways. n Annotated expression specifying detailed evaluation strategy is called an evaluation-plan. l E.g., can use an index on balance to find accounts with balance < 2500, l or can perform complete relation scan and discard accounts with balance  2500

©Silberschatz, Korth and Sudarshan13.5Database System Concepts - 5 th Edition, Aug 27, Basic Steps: Optimization (Cont.) n Query Optimization: Amongst all equivalent evaluation plans choose the one with lowest cost. l Cost is estimated using statistical information from the database catalog  e.g. number of tuples in each relation, size of tuples, etc. n In this chapter we study l How to measure query costs l Algorithms for evaluating relational algebra operations l How to combine algorithms for individual operations in order to evaluate a complete expression

©Silberschatz, Korth and Sudarshan13.6Database System Concepts - 5 th Edition, Aug 27, Measures of Query Cost n Cost is generally measured as total elapsed time for answering query l Many factors contribute to time cost  disk accesses, CPU, or even network communication n Typically disk access is the predominant cost, and is also relatively easy to estimate. Measured by taking into account l Number of seeks * average-seek-cost l Number of blocks read * average-block-read-cost l Number of blocks written * average-block-write-cost  Cost to write a block is greater than cost to read a block –data is read back after being written to ensure that the write was successful

©Silberschatz, Korth and Sudarshan13.7Database System Concepts - 5 th Edition, Aug 27, Measures of Query Cost (Cont.) n For simplicity we just use the number of block transfers from disk and the number of seeks as the cost measures l t T – time to transfer one block l t S – time for one seek l Cost for b block transfers plus S seeks b * t T + S * t S n We ignore CPU costs for simplicity l Real systems do take CPU cost into account n We do not include cost to writing output to disk in our cost formulae n Several algorithms can reduce disk IO by using extra buffer space l Amount of real memory available to buffer depends on other concurrent queries and OS processes, known only during execution  We often use worst case estimates, assuming only the minimum amount of memory needed for the operation is available n Required data may be buffer resident already, avoiding disk I/O l But hard to take into account for cost estimation

©Silberschatz, Korth and Sudarshan13.8Database System Concepts - 5 th Edition, Aug 27, Selection Operation n File scan – search algorithms that locate and retrieve records that fulfill a selection condition. n Algorithm A1 (linear search). Scan each file block and test all records to see whether they satisfy the selection condition. l Cost estimate = b r block transfers + 1 seek  b r denotes number of blocks containing records from relation r l If selection is on a key attribute, can stop on finding record  cost = ( b r /2) block transfers + 1 seek l Linear search can be applied regardless of  selection condition or  ordering of records in the file, or  availability of indices

©Silberschatz, Korth and Sudarshan13.9Database System Concepts - 5 th Edition, Aug 27, Selection Operation (Cont.) n A2 (binary search). Applicable if selection is an equality comparison on the attribute on which file is ordered. l Assume that the blocks of a relation are stored contiguously l Cost estimate (number of disk blocks to be scanned):  cost of locating the first tuple by a binary search on the blocks –  log 2 (b r )  * (t T + t S )  If there are multiple records satisfying selection –Add transfer cost of the number of blocks containing records that satisfy selection condition

©Silberschatz, Korth and Sudarshan13.10Database System Concepts - 5 th Edition, Aug 27, Selections Using Indices n Index scan – search algorithms that use an index l selection condition must be on search-key of index. n A3 (primary index on candidate key, equality). Retrieve a single record that satisfies the corresponding equality condition l Cost = (h i + 1) * (t T + t S ) n A4 (primary index on nonkey, equality) Retrieve multiple records. l Records will be on consecutive blocks  Let b = number of blocks containing matching records l Cost = h i * (t T + t S ) + t S + t T * b

©Silberschatz, Korth and Sudarshan13.11Database System Concepts - 5 th Edition, Aug 27, Selections Using Indices n A5 (equality on search-key of secondary index). l Retrieve a single record if the search-key is a candidate key  Cost = (h i + 1) * (t T + t S ) l Retrieve multiple records if search-key is not a candidate key  each of n matching records may be on a different block  Cost = (h i + n) * (t T + t S ) –Can be very expensive!

Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com End of Chapter