Query Execution Section 15.1 Shweta Athalye CS257: Database Systems ID: 118 Section 1.

Slides:



Advertisements
Similar presentations
CS 245Notes 71 CS 245: Database System Principles Notes 7: Query Optimization Hector Garcia-Molina.
Advertisements

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Algorithms for SELECT and JOIN Operations (8) Implementing the JOIN Operation: Join (EQUIJOIN, NATURAL.
CS 4432query processing - lecture 161 CS4432: Database Systems II Lecture #16 Join Processing Algorithms Professor Elke A. Rundensteiner.
CS 540 Database Management Systems
1 Lecture 23: Query Execution Friday, March 4, 2005.
CS CS4432: Database Systems II Operator Algorithms Chapter 15.
Implementation of Other Relational Algebra Operators, R. Ramakrishnan and J. Gehrke1 Implementation of other Relational Algebra Operators Chapter 12.
Database Management Systems, R. Ramakrishnan and Johannes Gehrke1 Evaluation of Relational Operations: Other Techniques Chapter 12, Part B.
Dr. Kalpakis CMSC 661, Principles of Database Systems Query Execution [15]
Completing the Physical-Query-Plan. Query compiler so far Parsed the query. Converted it to an initial logical query plan. Improved that logical query.
Query Execution Since our SQL queries are very high level the query processor does a lot of processing to supply all the details. An SQL query is translated.
Query Execution Optimizing Performance. Resolving an SQL query Since our SQL queries are very high level, the query processor must do a lot of additional.
COMP 451/651 Optimizing Performance
Query Execution Professor: Dr T.Y. Lin Prepared by, Mudra Patel Class id: 113.
Query Execution Professor: Dr T.Y. Lin Prepared by, Mudra Patel Class id: 113.
CS 245Notes 71 CS 245: Database System Principles Notes 7: Query Optimization Hector Garcia-Molina.
Lecture 24: Query Execution Monday, November 20, 2000.
CS 257, Spring’08 Presented By: Presented By: Gayatri Gopalakrishnan Gayatri Gopalakrishnan ID : 201.
CSCI 5708: Query Processing I Pusheng Zhang University of Minnesota Feb 3, 2004.
1 Lecture 22: Query Execution Wednesday, March 2, 2005.
Query Execution :Nested-Loop Joins Rohit Deshmukh ID 120 CS-257 Rohit Deshmukh ID 120 CS-257.
Query Execution Professor: Dr T.Y. Lin Prepared by, Mudra Patel Class id: 113.
Query Compiler: 16.7 Completing the Physical Query-Plan CS257 Spring 2009 Professor Tsau Lin Student: Suntorn Sae-Eung ID: 212.
CSCI 5708: Query Processing I Pusheng Zhang University of Minnesota Feb 3, 2004.
15.3 Nested-Loop Joins - Medha Pradhan - ID: CS 257 Section 2 - Spring 2008.
Query Execution Chapter 15 Section 15.1 Presented by Khadke, Suvarna CS 257 (Section II) Id
1 Relational Operators. 2 Outline Logical/physical operators Cost parameters and sorting One-pass algorithms Nested-loop joins Two-pass algorithms.
CPS216: Advanced Database Systems Notes 03:Query Processing (Overview, contd.) Shivnath Babu.
Query Optimization CS 157B Ch. 14 Mien Siao. Outline Introduction Steps in Cost-based query optimization- Query Flow Projection Example Query Interaction.
Query Optimization. overview Histograms A histogram is a data structure maintained by a DBMS to approximate a data distribution Equiwidth vs equidepth.
CSCE Database Systems Chapter 15: Query Execution 1.
Database Management 9. course. Execution of queries.
Query Execution Optimizing Performance. Resolving an SQL query Since our SQL queries are very high level, the query processor must do a lot of additional.
CPS216: Advanced Database Systems Notes 07:Query Execution Shivnath Babu.
Chapter 13 Query Processing Melissa Jamili CS 157B November 11, 2004.
Query Processing. Steps in Query Processing Validate and translate the query –Good syntax. –All referenced relations exist. –Translate the SQL to relational.
CS411 Database Systems Kazuhiro Minami 11: Query Execution.
CS 257 Chapter – 15.9 Summary of Query Execution Database Systems: The Complete Book Krishna Vellanki 124.
16.7 Completing the Physical- Query-Plan By Aniket Mulye CS257 Prof: Dr. T. Y. Lin.
CS4432: Database Systems II Query Processing- Part 2.
Query Processing – Query Trees. Evaluation of SQL Conceptual order of evaluation – Cartesian product of all tables in from clause – Rows not satisfying.
Query Optimization CMPE 226 Database Systems By, Arjun Gangisetty
Lecture 17: Query Execution Tuesday, February 28, 2001.
CS 440 Database Management Systems Lecture 5: Query Processing 1.
Completing the Physical- Query-Plan and Chapter 16 Summary ( ) CS257 Spring 2009 Professor Tsau Lin Student: Suntorn Sae-Eung Donavon Norwood.
CS 540 Database Management Systems
1 Lecture 23: Query Execution Monday, November 26, 2001.
Query Processing COMP3017 Advanced Databases Nicholas Gibbins
CS4432: Database Systems II Query Processing- Part 1 1.
Query Execution Chapter 15 Section 15.1 Presented by Khadke, Suvarna CS 257 (Section II) Id
15.1 – Introduction to physical-Query-plan operators
CS 540 Database Management Systems
Indexes By Adrienne Watt.
CS 440 Database Management Systems
CS222P: Principles of Data Management Lecture #15 Query Optimization (System-R) Instructor: Chen Li.
Chapter 12: Query Processing
Chapter 15 QUERY EXECUTION.
Query Execution Presented by Khadke, Suvarna CS 257
Sidharth Mishra Dr. T.Y. Lin CS 257 Section 1 MH 222 SJSU - Fall 2016
Query Optimization CS 157B Ch. 14 Mien Siao.
Chapters 15 and 16b: Query Optimization
One-Pass Algorithms for Database Operations (15.2)
Query Execution Presented by Jiten Oswal CS 257 Chapter 15
Chapter 12 Query Processing (1)
Lecture 23: Query Execution
Evaluation of Relational Operations: Other Techniques
Lecture 22: Query Execution
CS222: Principles of Data Management Lecture #15 Query Optimization (System-R) Instructor: Chen Li.
Lecture 24: Query Execution
Lecture 20: Query Execution
Presentation transcript:

Query Execution Section 15.1 Shweta Athalye CS257: Database Systems ID: 118 Section 1

Agenda Query Processor Query compilation Physical Query Plan Operators  Scanning Tables Table Scan Index scan Sorting while scanning tables Model of computation for physical operators Parameters for measuring cost I/O cost for scan operators Iterators

Query processor The query processor is the group of components of a DBMS that turns user queries and data-modification commands into a sequence of database operations and executes those operations query processor is responsible for supplying details regarding how the query is to be executed

The major parts of the query processor

Query compilation Query compilation itself is a multi-step process consisting of :  Parsing: in which a parse tree representing query and its structure is constructed  Query rewrite: in which the parse tree is converted to an initial query plan  Physical plan generation: where the abstract query plan is turned into a physical query plan

Outline of query compilation

Physical Query Plan Operators Physical query plans are built from operators Each of the operators implement one step of the plan. Physical operators can be implementations of the operator of relational algebra. They can also be non relational algebra operators like “scan” which scans tables.

Scanning Tables One of the most basic things in a physical query plan. Necessary when we want to perform join or union of a relation with another relation.

Two basic approaches to locating the tuples of a relation R Table-scan  Relation R is stored in secondary memory with its tuples arranged in blocks  it is possible to get the blocks one by one  This operation is called Table Scan

Two basic approaches to locating the tuples of a relation R Index-scan  there is an index on any attribute of Relation R  Use this index to get all the tuples of R  This operation is called Index Scan

Sorting While Scanning Tables Why do we need sorting while scanning?  the query could include an ORDER BY clause. Requiring that a relation be sorted  Various algorithms for relational-algebra operations require one or both of their arguments to be sorted relation  physical-query-plan operator sort-scan takes a relation R and a specification of the attributes on which the sort is to be made, and produces R in that sorted order

Model of Computation for Physical Operators Choosing physical plan operators wisely is an essential for a good query processor. Cost for an operation is measured in number of disk i/o operations. If an operator requires the final answer to a query to be written back to the disk, the total cost will depend on the length of the answer and will include the final write back cost to the total cost of the query.

Improvements in cost Major improvements in cost of the physical operators can be achieved by avoiding or reducing the number of disk i/o operations This can be achieved by passing the answer of one operator to the other in the main memory itself without writing it to the disk.

Parameters for Measuring Costs Parameters that affect the performance of a query  Buffer space availability in the main memory at the time of execution of the query  Size of input and the size of the output generated  The size of memory block on the disk and the size in the main memory also affects the performance

I/0 Cost for Scan Operators If Relation R is clustered, i.e. it is stored in approximately B blocks then the total number of disk operations required is B If R is clustered but requires a two phase multi way merge sort then the total number of disk i/o required will be 3B. However, if R is not clustered, then the number of required disk I/0's is generally much higher.

Iterators for Implementation of Physical Operators Many physical operators can be implemented as an iterator It is a group of three functions that allows a consumer of the result of the physical operator to get the result one tuple at a time

Iterator The three functions forming the iterator are: Open: This function starts the process of getting tuples. It initializes any data structures needed to perform the operation

Iterator GetNext This function returns the next tuple in the result Adjusts data structures as necessary to allow subsequent tuples to be obtained If there are no more tuples to return, GetNext returns a special value NotFound

Iterator Close This function ends the iteration after all tuples it calls Close on any arguments of the operator