Query Evaluation and Optimization

Size: px
Start display at page:

Download "Query Evaluation and Optimization"

Transcription

1 Query Evaluation and Optimization Jan Chomicki University at Buffalo Jan Chomicki () Query Evaluation and Optimization 1 / 21

2 Evaluating σ E (R) Jan Chomicki () Query Evaluation and Optimization 2 / 21

3 Evaluating σ E (R) Pick the option of least estimated cost. Jan Chomicki () Query Evaluation and Optimization 2 / 21

4 Evaluating σ E (R) Pick the option of least estimated cost. Any E Linear (sequential) scan. Jan Chomicki () Query Evaluation and Optimization 2 / 21

5 Evaluating σ E (R) Pick the option of least estimated cost. Any E Linear (sequential) scan. E is A = c if file sorted on A, use binary search if file has an index on A, use the index if file hashed on A, use hashing Jan Chomicki () Query Evaluation and Optimization 2 / 21

6 Evaluating σ E (R) Pick the option of least estimated cost. Any E Linear (sequential) scan. E is A = c if file sorted on A, use binary search if file has an index on A, use the index if file hashed on A, use hashing E is Aθc for θ {<,, >, } if file sorted on A, then: use binary search if there is an index on A, use the index Jan Chomicki () Query Evaluation and Optimization 2 / 21

7 Complex selection conditions Jan Chomicki () Query Evaluation and Optimization 3 / 21

8 Complex selection conditions E is E 1 E 2 use E 1 or E 2 to narrow down the search use composite index (if available) use indexes for E 1 and E 2 to obtain sets of RowIds, then intersect those sets use bitmap indexes for E 1 and E 2 to obtain bitvectors, then use boolean AND use a combination of bitmap and other kinds of indexes Jan Chomicki () Query Evaluation and Optimization 3 / 21

9 Complex selection conditions E is E 1 E 2 use E 1 or E 2 to narrow down the search use composite index (if available) use indexes for E 1 and E 2 to obtain sets of RowIds, then intersect those sets use bitmap indexes for E 1 and E 2 to obtain bitvectors, then use boolean AND use a combination of bitmap and other kinds of indexes E is E 1 E 2 E 1 or E 2 cannot be used separately to narrow down the search use indexes for E 1 and E 2 to obtain sets of RowIds, then take the union of those sets use bitmap indexes for E 1 and E 2 to obtain bitvectors, then use boolean OR use a combination of bitmap and other kinds of indexes Jan Chomicki () Query Evaluation and Optimization 3 / 21

10 Evaluating R A=B S Jan Chomicki () Query Evaluation and Optimization 4 / 21

11 Evaluating R A=B S Nested loops foreach t R do foreach s S do if t[a] = s[b] then output (t, s) Jan Chomicki () Query Evaluation and Optimization 4 / 21

12 Evaluating R A=B S Nested loops foreach t R do foreach s S do if t[a] = s[b] then output (t, s) Index join (S has an index on B) foreach t R do lookup S using the index and the value t[a] Jan Chomicki () Query Evaluation and Optimization 4 / 21

13 Evaluating R A=B S Nested loops foreach t R do foreach s S do if t[a] = s[b] then output (t, s) Index join (S has an index on B) foreach t R do lookup S using the index and the value t[a] Sort-merge join (R sorted on A, S sorted on B) scan files in sorted order matching A-values in R with B-values in S Jan Chomicki () Query Evaluation and Optimization 4 / 21

14 Jan Chomicki () Query Evaluation and Optimization 5 / 21

15 Hash-join create new hashed files HR and HS; foreach t R do i := h(t[a]); store t in bucket r i of HR; foreach t S do i := h(t[a]); store t in bucket s i of HS; for each bucket r i of HR read r i and build an in-memory hash index for each tuple t in the bucket s i of S probe the hash index to find and output the tuples w such that w[a] = t[a] Jan Chomicki () Query Evaluation and Optimization 5 / 21

16 Hash-join create new hashed files HR and HS; foreach t R do i := h(t[a]); store t in bucket r i of HR; foreach t S do i := h(t[a]); store t in bucket s i of HS; for each bucket r i of HR read r i and build an in-memory hash index for each tuple t in the bucket s i of S probe the hash index to find and output the tuples w such that w[a] = t[a] the hash function used to build the hash index and to probe it has to be different than h each bucket of HR has to fit in main memory Jan Chomicki () Query Evaluation and Optimization 5 / 21

17 Oracle: selection and join Jan Chomicki () Query Evaluation and Optimization 6 / 21

18 Oracle: selection and join Equality condition A = c unique index on A: INDEX UNIQUE SCAN nonunique index on A: INDEX RANGE SCAN Jan Chomicki () Query Evaluation and Optimization 6 / 21

19 Oracle: selection and join Equality condition A = c unique index on A: INDEX UNIQUE SCAN nonunique index on A: INDEX RANGE SCAN Range condition on A any index on A: INDEX RANGE SCAN Jan Chomicki () Query Evaluation and Optimization 6 / 21

20 Oracle: selection and join Equality condition A = c unique index on A: INDEX UNIQUE SCAN nonunique index on A: INDEX RANGE SCAN Range condition on A any index on A: INDEX RANGE SCAN Conjunction both indexes: AND-EQUAL (intersection of RowId sets) Jan Chomicki () Query Evaluation and Optimization 6 / 21

21 Oracle: selection and join Equality condition A = c unique index on A: INDEX UNIQUE SCAN nonunique index on A: INDEX RANGE SCAN Range condition on A any index on A: INDEX RANGE SCAN Conjunction both indexes: AND-EQUAL (intersection of RowId sets) Join 1 SORT JOIN/MERGE JOIN (sort-merge) 2 NESTED LOOPS (nested loop or index join) 3 HASH JOIN Jan Chomicki () Query Evaluation and Optimization 6 / 21

22 Query optimization Jan Chomicki () Query Evaluation and Optimization 7 / 21

23 Query optimization Stages: 1 Parsing, validation, view expansion. 2 Logical plan selection (using algebraic laws). 3 Physical plan selection (cost-based) Jan Chomicki () Query Evaluation and Optimization 7 / 21

24 Algebraic laws Jan Chomicki () Query Evaluation and Optimization 8 / 21

25 Algebraic laws Assumption Tuples are mappings from attribute names to domain values. Jan Chomicki () Query Evaluation and Optimization 8 / 21

26 Algebraic laws Assumption Tuples are mappings from attribute names to domain values. Join (and Cartesian product) E 1 E 2 = E 2 E 1 (E 1 E 2 ) E 3 = E 1 (E 2 E 3 ). Jan Chomicki () Query Evaluation and Optimization 8 / 21

27 Algebraic laws Assumption Tuples are mappings from attribute names to domain values. Join (and Cartesian product) E 1 E 2 = E 2 E 1 (E 1 E 2 ) E 3 = E 1 (E 2 E 3 ). Cascading π A1,...,A n (π A1,...,A n,...,a n+k (E)) = π A1,...,A n (E) σ F1 (σ F2 (E)) = σ F1 F 2 (E) Jan Chomicki () Query Evaluation and Optimization 8 / 21

28 Commuting projections Jan Chomicki () Query Evaluation and Optimization 9 / 21

29 Commuting projections With selection π A1,...,A n (σ F (E)) = σ F (π A1,...,A n (E)) if F does not involve any attributes othet than A 1,..., A n. Jan Chomicki () Query Evaluation and Optimization 9 / 21

30 Commuting projections With selection π A1,...,A n (σ F (E)) = σ F (π A1,...,A n (E)) if F does not involve any attributes othet than A 1,..., A n. With Cartesian product π A1,...,A n,a n+1,...,a n+k (E 1 E 2 ) = π A1,...,A n (E 1 ) π An+1,...,A n+k (E 2 ) where A 1,..., A n come from E 1 and A n+1,..., A n+k come from E 2. Jan Chomicki () Query Evaluation and Optimization 9 / 21

31 Commuting projections With selection π A1,...,A n (σ F (E)) = σ F (π A1,...,A n (E)) if F does not involve any attributes othet than A 1,..., A n. With Cartesian product π A1,...,A n,a n+1,...,a n+k (E 1 E 2 ) = π A1,...,A n (E 1 ) π An+1,...,A n+k (E 2 ) where A 1,..., A n come from E 1 and A n+1,..., A n+k come from E 2. With union π A1,...,A n (E 1 E 2 ) = π A1,...,A n (E 1 ) π A1,...,A n (E 2 ). Jan Chomicki () Query Evaluation and Optimization 9 / 21

32 Commuting selections Jan Chomicki () Query Evaluation and Optimization 10 / 21

33 Commuting selections With Cartesian product σ F (E 1 E 2 ) = σ F (E 1 ) E 2 if F involves only the attributes of E 1. Jan Chomicki () Query Evaluation and Optimization 10 / 21

34 Commuting selections With Cartesian product σ F (E 1 E 2 ) = σ F (E 1 ) E 2 if F involves only the attributes of E 1. With union σ F (E 1 E 2 ) = σ F (E 1 ) σ F (E 2 ). Jan Chomicki () Query Evaluation and Optimization 10 / 21

35 Commuting selections With Cartesian product σ F (E 1 E 2 ) = σ F (E 1 ) E 2 if F involves only the attributes of E 1. With union σ F (E 1 E 2 ) = σ F (E 1 ) σ F (E 2 ). With set difference σ F (E 1 E 2 ) = σ F (E 1 ) σ F (E 2 ). Jan Chomicki () Query Evaluation and Optimization 10 / 21

36 Cost-based query optimization Logical query plan expression in relational algebra produced by rewrite rules that are obtained from the algebraic laws. Physical query plan operators: different implementations of relational algebra operators table-scan, index-scan, sort-scan, sort. Jan Chomicki () Query Evaluation and Optimization 11 / 21

37 Cost-based query optimization Logical query plan expression in relational algebra produced by rewrite rules that are obtained from the algebraic laws. Physical query plan operators: different implementations of relational algebra operators table-scan, index-scan, sort-scan, sort. A physical query plan of least estimated cost is produced from a logical query plan. Jan Chomicki () Query Evaluation and Optimization 11 / 21

38 Choices to be made Jan Chomicki () Query Evaluation and Optimization 12 / 21

39 Choices to be made 1 order and grouping of joins 2 choosing an algorithm for each operator occurrence 3 adding other operators like sorting 4 materialization vs. pipelining Jan Chomicki () Query Evaluation and Optimization 12 / 21

40 Choices to be made 1 order and grouping of joins 2 choosing an algorithm for each operator occurrence 3 adding other operators like sorting 4 materialization vs. pipelining Assumptions relation file cost size of intermediate relations Jan Chomicki () Query Evaluation and Optimization 12 / 21

41 Cost estimation using size estimates Jan Chomicki () Query Evaluation and Optimization 13 / 21

42 Cost estimation using size estimates Size estimates accurate easy to compute consistent Jan Chomicki () Query Evaluation and Optimization 13 / 21

43 Cost estimation using size estimates Size estimates accurate easy to compute consistent Notation B(R): number of blocks in relation R T (R): number of tuples in relation R V (R, A): number of distinct values R has in attribute A (can be generalized to sets of attributes) Jan Chomicki () Query Evaluation and Optimization 13 / 21

44 Relational algebra operators Jan Chomicki () Query Evaluation and Optimization 14 / 21

45 Relational algebra operators Projection T (π X (R)) = T (R) Jan Chomicki () Query Evaluation and Optimization 14 / 21

46 Relational algebra operators Projection T (π X (R)) = T (R) Selection T (σ A=c (R)) = T (R)/V (R, A) T (σ A<c (R) = T (R)/3 T (σ C1 C 2 (R) = T (σ C1 (σ C2 (R))) T (σ C1 C 2 (R)) = min(t (R), T (σ C1 (R)) + T (σ C2 (R))) Jan Chomicki () Query Evaluation and Optimization 14 / 21

47 Relational algebra operators Projection T (π X (R)) = T (R) Selection T (σ A=c (R)) = T (R)/V (R, A) T (σ A<c (R) = T (R)/3 T (σ C1 C 2 (R) = T (σ C1 (σ C2 (R))) T (σ C1 C 2 (R)) = min(t (R), T (σ C1 (R)) + T (σ C2 (R))) Those estimates may be inconsistent. Jan Chomicki () Query Evaluation and Optimization 14 / 21

48 Natural join R(X, Y ) S(Y, Z) Simplifying assumptions containment: V (R, Y ) V (S, Y ) implies π Y (R) π Y (S) preservation: V (R S, A) = V (R, A). Jan Chomicki () Query Evaluation and Optimization 15 / 21

49 Natural join R(X, Y ) S(Y, Z) Simplifying assumptions containment: V (R, Y ) V (S, Y ) implies π Y (R) π Y (S) preservation: V (R S, A) = V (R, A). Y consists of one attribute A T (R S) = T (R)T (S) max(v (R, A), V (S, A)). Jan Chomicki () Query Evaluation and Optimization 15 / 21

50 Natural join R(X, Y ) S(Y, Z) Simplifying assumptions containment: V (R, Y ) V (S, Y ) implies π Y (R) π Y (S) preservation: V (R S, A) = V (R, A). Y consists of one attribute A T (R S) = T (R)T (S) max(v (R, A), V (S, A)). Y consists of n attributes A 1,..., A n T (R S) = T (R)T (S) j=1,...,n max(v (R, A j), V (S, A j )). Jan Chomicki () Query Evaluation and Optimization 15 / 21

51 Multiway join S = R 1 R k Assumption A 1,... A n are the attributes that appear in more than one relation. Jan Chomicki () Query Evaluation and Optimization 16 / 21

52 Multiway join S = R 1 R k Assumption A 1,... A n are the attributes that appear in more than one relation. A-factor M(A) Product of V (R i, A) for every relation R i in which A appears, except for the smallest V (R i, A). Jan Chomicki () Query Evaluation and Optimization 16 / 21

53 Multiway join S = R 1 R k Assumption A 1,... A n are the attributes that appear in more than one relation. A-factor M(A) Product of V (R i, A) for every relation R i in which A appears, except for the smallest V (R i, A). Multiway join size T (R 1 R k ) = i=1,...,k T (R i) j=1,...,n M(A j). Jan Chomicki () Query Evaluation and Optimization 16 / 21

54 Jan Chomicki () Query Evaluation and Optimization 17 / 21

55 Properties consistency: join size estimate is independent of the order and the grouping of the joins accuracy: better estimates exist, for example based on histograms Jan Chomicki () Query Evaluation and Optimization 17 / 21

56 Properties consistency: join size estimate is independent of the order and the grouping of the joins accuracy: better estimates exist, for example based on histograms Statistics computed periodically, on-demand or incrementally do not have to be very accurate Jan Chomicki () Query Evaluation and Optimization 17 / 21

57 Computing the best plan for R 1 R k Jan Chomicki () Query Evaluation and Optimization 18 / 21

58 Computing the best plan for R 1 R k Constructing a table D(Size,LeastCost,BestPlan) Base cases: One relation R: D(T (R), 0, R) One join Ri R j : D(T (R i R j ), 0, R i R j ) if T (R i ) T (R j ) Inductive case R : 1 R = {R i1,..., R im } for m < k 2 for every j {i 1,..., i m}, retrieve the tuple D(T ( i j,r i R R i), C j, E j ) 3 find p {i 1,..., i m} such that C p + T (( i p,r i R R i)) is minimal 4 let Best = ( i p,r i R R i) 5 return D(T (Best R p), C p + T (Best), E p R p) Jan Chomicki () Query Evaluation and Optimization 18 / 21

59 Computing the best plan for R 1 R k Constructing a table D(Size,LeastCost,BestPlan) Base cases: One relation R: D(T (R), 0, R) One join Ri R j : D(T (R i R j ), 0, R i R j ) if T (R i ) T (R j ) Inductive case R : 1 R = {R i1,..., R im } for m < k 2 for every j {i 1,..., i m}, retrieve the tuple D(T ( i j,r i R R i), C j, E j ) 3 find p {i 1,..., i m} such that C p + T (( i p,r i R R i)) is minimal 4 let Best = ( i p,r i R R i) 5 return D(T (Best R p), C p + T (Best), E p R p) How many plans are considered? Jan Chomicki () Query Evaluation and Optimization 18 / 21

60 Refinements More sophisticated cost measure calculating the cost of using different algorithms for the same operation keeping multiple plans, together with their costs, to account for interesting join orders. Jan Chomicki () Query Evaluation and Optimization 19 / 21

61 Refinements More sophisticated cost measure calculating the cost of using different algorithms for the same operation keeping multiple plans, together with their costs, to account for interesting join orders. Greedy algorithm 1 start with a pair of relations whose estimated join size is minimal 2 keep adding further relations with minimal estimated join size Jan Chomicki () Query Evaluation and Optimization 19 / 21

62 Completing the evaluation plan Operations TableScan(Relation) SortScan(Relation, Attributes) IndexScan(Relation, Condition) Filter(Condition) Sort(Attributes) different algorithms for the basic operations Jan Chomicki () Query Evaluation and Optimization 20 / 21

63 Completing the evaluation plan Operations TableScan(Relation) SortScan(Relation, Attributes) IndexScan(Relation, Condition) Filter(Condition) Sort(Attributes) different algorithms for the basic operations Pipelining vs. materialization. Jan Chomicki () Query Evaluation and Optimization 20 / 21

64 Jan Chomicki () Query Evaluation and Optimization 21 / 21

Storage hierarchy. Textbook: chapters 11, 12, and 13

Storage hierarchy. Textbook: chapters 11, 12, and 13 Storage hierarchy Cache Main memory Disk Tape Very fast Fast Slower Slow Very small Small Bigger Very big (KB) (MB) (GB) (TB) Built-in Expensive Cheap Dirt cheap Disks: data is stored on concentric circular

More information

Introduction to Query Processing and Query Optimization Techniques. Copyright 2011 Ramez Elmasri and Shamkant Navathe

Introduction to Query Processing and Query Optimization Techniques. Copyright 2011 Ramez Elmasri and Shamkant Navathe Introduction to Query Processing and Query Optimization Techniques Outline Translating SQL Queries into Relational Algebra Algorithms for External Sorting Algorithms for SELECT and JOIN Operations Algorithms

More information

Relational Databases

Relational Databases Relational Databases Jan Chomicki University at Buffalo Jan Chomicki () Relational databases 1 / 49 Plan of the course 1 Relational databases 2 Relational database design 3 Conceptual database design 4

More information

Chapter 12: Query Processing

Chapter 12: Query Processing Chapter 12: Query Processing Overview Catalog Information for Cost Estimation $ Measures of Query Cost Selection Operation Sorting Join Operation Other Operations Evaluation of Expressions Transformation

More information

Outline. Query Processing Overview Algorithms for basic operations. Query optimization. Sorting Selection Join Projection

Outline. Query Processing Overview Algorithms for basic operations. Query optimization. Sorting Selection Join Projection Outline Query Processing Overview Algorithms for basic operations Sorting Selection Join Projection Query optimization Heuristics Cost-based optimization 19 Estimate I/O Cost for Implementations Count

More information

CMSC424: Database Design. Instructor: Amol Deshpande

CMSC424: Database Design. Instructor: Amol Deshpande CMSC424: Database Design Instructor: Amol Deshpande amol@cs.umd.edu Databases Data Models Conceptual representa1on of the data Data Retrieval How to ask ques1ons of the database How to answer those ques1ons

More information

Database System Concepts

Database System Concepts Chapter 13: Query Processing s Departamento de Engenharia Informática Instituto Superior Técnico 1 st Semester 2008/2009 Slides (fortemente) baseados nos slides oficiais do livro c Silberschatz, Korth

More information

Algorithms for Query Processing and Optimization. 0. Introduction to Query Processing (1)

Algorithms for Query Processing and Optimization. 0. Introduction to Query Processing (1) Chapter 19 Algorithms for Query Processing and Optimization 0. Introduction to Query Processing (1) Query optimization: The process of choosing a suitable execution strategy for processing a query. Two

More information

Chapter 13: Query Processing

Chapter 13: Query Processing Chapter 13: Query Processing! Overview! Measures of Query Cost! Selection Operation! Sorting! Join Operation! Other Operations! Evaluation of Expressions 13.1 Basic Steps in Query Processing 1. Parsing

More information

Query Processing. Introduction to Databases CompSci 316 Fall 2017

Query Processing. Introduction to Databases CompSci 316 Fall 2017 Query Processing Introduction to Databases CompSci 316 Fall 2017 2 Announcements (Tue., Nov. 14) Homework #3 sample solution posted in Sakai Homework #4 assigned today; due on 12/05 Project milestone #2

More information

Query Processing & Optimization

Query Processing & Optimization Query Processing & Optimization 1 Roadmap of This Lecture Overview of query processing Measures of Query Cost Selection Operation Sorting Join Operation Other Operations Evaluation of Expressions Introduction

More information

Principles of Database Management Systems

Principles of Database Management Systems Principles of Database Management Systems 5: Query Processing Pekka Kilpeläinen (partially based on Stanford CS245 slide originals by Hector Garcia-Molina, Jeff Ullman and Jennifer Widom) Query Processing

More information

Chapter 12: Query Processing

Chapter 12: Query Processing Chapter 12: Query Processing Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Overview Chapter 12: Query Processing Measures of Query Cost Selection Operation Sorting Join

More information

Indexing. Jan Chomicki University at Buffalo. Jan Chomicki () Indexing 1 / 25

Indexing. Jan Chomicki University at Buffalo. Jan Chomicki () Indexing 1 / 25 Indexing Jan Chomicki University at Buffalo Jan Chomicki () Indexing 1 / 25 Storage hierarchy Cache Main memory Disk Tape Very fast Fast Slower Slow (nanosec) (10 nanosec) (millisec) (sec) Very small Small

More information

! A relational algebra expression may have many equivalent. ! Cost is generally measured as total elapsed time for

! A relational algebra expression may have many equivalent. ! Cost is generally measured as total elapsed time for Chapter 13: Query Processing Basic Steps in Query Processing! Overview! Measures of Query Cost! Selection Operation! Sorting! Join Operation! Other Operations! Evaluation of Expressions 1. Parsing and

More information

Chapter 13: Query Processing Basic Steps in Query Processing

Chapter 13: Query Processing Basic Steps in Query Processing Chapter 13: Query Processing Basic Steps in Query Processing! Overview! Measures of Query Cost! Selection Operation! Sorting! Join Operation! Other Operations! Evaluation of Expressions 1. Parsing and

More information

Statistics. Duplicate Elimination

Statistics. Duplicate Elimination Query Execution 1. Parse query into a relational algebra expression tree. 2. Optimize relational algebra expression tree and select implementations for the relational algebra operators. (This step involves

More information

Query Processing. Debapriyo Majumdar Indian Sta4s4cal Ins4tute Kolkata DBMS PGDBA 2016

Query Processing. Debapriyo Majumdar Indian Sta4s4cal Ins4tute Kolkata DBMS PGDBA 2016 Query Processing Debapriyo Majumdar Indian Sta4s4cal Ins4tute Kolkata DBMS PGDBA 2016 Slides re-used with some modification from www.db-book.com Reference: Database System Concepts, 6 th Ed. By Silberschatz,

More information

Query Optimization. Query Optimization. Optimization considerations. Example. Interaction of algorithm choice and tree arrangement.

Query Optimization. Query Optimization. Optimization considerations. Example. Interaction of algorithm choice and tree arrangement. COS 597: Principles of Database and Information Systems Query Optimization Query Optimization Query as expression over relational algebraic operations Get evaluation (parse) tree Leaves: base relations

More information

Faloutsos 1. Carnegie Mellon Univ. Dept. of Computer Science Database Applications. Outline

Faloutsos 1. Carnegie Mellon Univ. Dept. of Computer Science Database Applications. Outline Carnegie Mellon Univ. Dept. of Computer Science 15-415 - Database Applications Lecture #14: Implementation of Relational Operations (R&G ch. 12 and 14) 15-415 Faloutsos 1 introduction selection projection

More information

Chapter 12: Query Processing. Chapter 12: Query Processing

Chapter 12: Query Processing. Chapter 12: Query Processing Chapter 12: Query Processing Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 12: Query Processing Overview Measures of Query Cost Selection Operation Sorting Join

More information

Query Processing. Solutions to Practice Exercises Query:

Query Processing. Solutions to Practice Exercises Query: C H A P T E R 1 3 Query Processing Solutions to Practice Exercises 13.1 Query: Π T.branch name ((Π branch name, assets (ρ T (branch))) T.assets>S.assets (Π assets (σ (branch city = Brooklyn )(ρ S (branch)))))

More information

From SQL-query to result Have a look under the hood

From SQL-query to result Have a look under the hood From SQL-query to result Have a look under the hood Classical view on RA: sets Theory of relational databases: table is a set Practice (SQL): a relation is a bag of tuples R π B (R) π B (R) A B 1 1 2

More information

What happens. 376a. Database Design. Execution strategy. Query conversion. Next. Two types of techniques

What happens. 376a. Database Design. Execution strategy. Query conversion. Next. Two types of techniques 376a. Database Design Dept. of Computer Science Vassar College http://www.cs.vassar.edu/~cs376 Class 16 Query optimization What happens Database is given a query Query is scanned - scanner creates a list

More information

CS 4604: Introduction to Database Management Systems. B. Aditya Prakash Lecture #10: Query Processing

CS 4604: Introduction to Database Management Systems. B. Aditya Prakash Lecture #10: Query Processing CS 4604: Introduction to Database Management Systems B. Aditya Prakash Lecture #10: Query Processing Outline introduction selection projection join set & aggregate operations Prakash 2018 VT CS 4604 2

More information

Query Processing Strategies and Optimization

Query Processing Strategies and Optimization Query Processing Strategies and Optimization CPS352: Database Systems Simon Miner Gordon College Last Revised: 10/25/12 Agenda Check-in Design Project Presentations Query Processing Programming Project

More information

Chapter 3. Algorithms for Query Processing and Optimization

Chapter 3. Algorithms for Query Processing and Optimization Chapter 3 Algorithms for Query Processing and Optimization Chapter Outline 1. Introduction to Query Processing 2. Translating SQL Queries into Relational Algebra 3. Algorithms for External Sorting 4. Algorithms

More information

Course No: 4411 Database Management Systems Fall 2008 Midterm exam

Course No: 4411 Database Management Systems Fall 2008 Midterm exam Course No: 4411 Database Management Systems Fall 2008 Midterm exam Last Name: First Name: Student ID: Exam is 80 minutes. Open books/notes The exam is out of 20 points. 1 1. (16 points) Multiple Choice

More information

Evaluation of Relational Operations

Evaluation of Relational Operations Evaluation of Relational Operations Chapter 12, Part A Database Management Systems, R. Ramakrishnan and J. Gehrke 1 Relational Operations We will consider how to implement: Selection ( ) Selects a subset

More information

Parser: SQL parse tree

Parser: SQL parse tree Jinze Liu Parser: SQL parse tree Good old lex & yacc Detect and reject syntax errors Validator: parse tree logical plan Detect and reject semantic errors Nonexistent tables/views/columns? Insufficient

More information

Announcement. Reading Material. Overview of Query Evaluation. Overview of Query Evaluation. Overview of Query Evaluation 9/26/17

Announcement. Reading Material. Overview of Query Evaluation. Overview of Query Evaluation. Overview of Query Evaluation 9/26/17 Announcement CompSci 516 Database Systems Lecture 10 Query Evaluation and Join Algorithms Project proposal pdf due on sakai by 5 pm, tomorrow, Thursday 09/27 One per group by any member Instructor: Sudeepa

More information

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe CHAPTER 19 Query Optimization Introduction Query optimization Conducted by a query optimizer in a DBMS Goal: select best available strategy for executing query Based on information available Most RDBMSs

More information

Database Management System

Database Management System Database Management System Lecture Join * Some materials adapted from R. Ramakrishnan, J. Gehrke and Shawn Bowers Today s Agenda Join Algorithm Database Management System Join Algorithms Database Management

More information

Database Systems. Announcement. December 13/14, 2006 Lecture #10. Assignment #4 is due next week.

Database Systems. Announcement. December 13/14, 2006 Lecture #10. Assignment #4 is due next week. Database Systems ( 料 ) December 13/14, 2006 Lecture #10 1 Announcement Assignment #4 is due next week. 2 1 Overview of Query Evaluation Chapter 12 3 Outline Query evaluation (Overview) Relational Operator

More information

Query Processing: The Basics. External Sorting

Query Processing: The Basics. External Sorting Query Processing: The Basics Chapter 10 1 External Sorting Sorting is used in implementing many relational operations Problem: Relations are typically large, do not fit in main memory So cannot use traditional

More information

15-415/615 Faloutsos 1

15-415/615 Faloutsos 1 Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Lecture #14: Implementation of Relational Operations (R&G ch. 12 and 14) 15-415/615 Faloutsos 1 Outline introduction selection

More information

Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Chapter 6 Outline. Unary Relational Operations: SELECT and

Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Chapter 6 Outline. Unary Relational Operations: SELECT and Chapter 6 The Relational Algebra and Relational Calculus Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 6 Outline Unary Relational Operations: SELECT and PROJECT Relational

More information

DBMS Y3/S5. 1. OVERVIEW The steps involved in processing a query are: 1. Parsing and translation. 2. Optimization. 3. Evaluation.

DBMS Y3/S5. 1. OVERVIEW The steps involved in processing a query are: 1. Parsing and translation. 2. Optimization. 3. Evaluation. Query Processing QUERY PROCESSING refers to the range of activities involved in extracting data from a database. The activities include translation of queries in high-level database languages into expressions

More information

EECS 647: Introduction to Database Systems

EECS 647: Introduction to Database Systems EECS 647: Introduction to Database Systems Instructor: Luke Huan Spring 2009 External Sorting Today s Topic Implementing the join operation 4/8/2009 Luke Huan Univ. of Kansas 2 Review DBMS Architecture

More information

Cost-based Query Sub-System. Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications. Last Class.

Cost-based Query Sub-System. Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications. Last Class. Cost-based Query Sub-System Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Queries Select * From Blah B Where B.blah = blah Query Parser Query Optimizer C. Faloutsos A. Pavlo

More information

Query optimization. Elena Baralis, Silvia Chiusano Politecnico di Torino. DBMS Architecture D B M G. Database Management Systems. Pag.

Query optimization. Elena Baralis, Silvia Chiusano Politecnico di Torino. DBMS Architecture D B M G. Database Management Systems. Pag. Database Management Systems DBMS Architecture SQL INSTRUCTION OPTIMIZER MANAGEMENT OF ACCESS METHODS CONCURRENCY CONTROL BUFFER MANAGER RELIABILITY MANAGEMENT Index Files Data Files System Catalog DATABASE

More information

Query Processing and Advanced Queries. Query Optimization (4)

Query Processing and Advanced Queries. Query Optimization (4) Query Processing and Advanced Queries Query Optimization (4) Two-Pass Algorithms Based on Hashing R./S If both input relations R and S are too large to be stored in the buffer, hash all the tuples of both

More information

Midterm Review. March 27, 2017

Midterm Review. March 27, 2017 Midterm Review March 27, 2017 1 Overview Relational Algebra & Query Evaluation Relational Algebra Rewrites Index Design / Selection Physical Layouts 2 Relational Algebra & Query Evaluation 3 Relational

More information

CSE Midterm - Spring 2017 Solutions

CSE Midterm - Spring 2017 Solutions CSE Midterm - Spring 2017 Solutions March 28, 2017 Question Points Possible Points Earned A.1 10 A.2 10 A.3 10 A 30 B.1 10 B.2 25 B.3 10 B.4 5 B 50 C 20 Total 100 Extended Relational Algebra Operator Reference

More information

Database Management Systems Written Examination

Database Management Systems Written Examination Database Management Systems Written Examination 14.02.2007 First name Student number Last name Signature Instructions for Students Write your name, student number, and signature on the exam sheet. Write

More information

CSE 544 Principles of Database Management Systems. Magdalena Balazinska Fall 2007 Lecture 9 - Query optimization

CSE 544 Principles of Database Management Systems. Magdalena Balazinska Fall 2007 Lecture 9 - Query optimization CSE 544 Principles of Database Management Systems Magdalena Balazinska Fall 2007 Lecture 9 - Query optimization References Access path selection in a relational database management system. Selinger. et.

More information

Chapter 13: Query Optimization. Chapter 13: Query Optimization

Chapter 13: Query Optimization. Chapter 13: Query Optimization Chapter 13: Query Optimization Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 13: Query Optimization Introduction Equivalent Relational Algebra Expressions Statistical

More information

Chapter 18 Strategies for Query Processing. We focus this discussion w.r.t RDBMS, however, they are applicable to OODBS.

Chapter 18 Strategies for Query Processing. We focus this discussion w.r.t RDBMS, however, they are applicable to OODBS. Chapter 18 Strategies for Query Processing We focus this discussion w.r.t RDBMS, however, they are applicable to OODBS. 1 1. Translating SQL Queries into Relational Algebra and Other Operators - SQL is

More information

Relational Algebra and SQL. Basic Operations Algebra of Bags

Relational Algebra and SQL. Basic Operations Algebra of Bags Relational Algebra and SQL Basic Operations Algebra of Bags 1 What is an Algebra Mathematical system consisting of: Operands --- variables or values from which new values can be constructed. Operators

More information

Database System Concepts

Database System Concepts Chapter 14: Optimization Departamento de Engenharia Informática Instituto Superior Técnico 1 st Semester 2007/2008 Slides (fortemente) baseados nos slides oficiais do livro c Silberschatz, Korth and Sudarshan.

More information

Chapter 14 Query Optimization

Chapter 14 Query Optimization Chapter 14 Query Optimization Chapter 14: Query Optimization! Introduction! Catalog Information for Cost Estimation! Estimation of Statistics! Transformation of Relational Expressions! Dynamic Programming

More information

Chapter 14 Query Optimization

Chapter 14 Query Optimization Chapter 14 Query Optimization Chapter 14: Query Optimization! Introduction! Catalog Information for Cost Estimation! Estimation of Statistics! Transformation of Relational Expressions! Dynamic Programming

More information

Chapter 14 Query Optimization

Chapter 14 Query Optimization Chapter 14: Query Optimization Chapter 14 Query Optimization! Introduction! Catalog Information for Cost Estimation! Estimation of Statistics! Transformation of Relational Expressions! Dynamic Programming

More information

CSE 544 Principles of Database Management Systems. Alvin Cheung Fall 2015 Lecture 7 - Query optimization

CSE 544 Principles of Database Management Systems. Alvin Cheung Fall 2015 Lecture 7 - Query optimization CSE 544 Principles of Database Management Systems Alvin Cheung Fall 2015 Lecture 7 - Query optimization Announcements HW1 due tonight at 11:45pm HW2 will be due in two weeks You get to implement your own

More information

Lecture Query evaluation. Cost-based transformations. By Marina Barsky Winter 2016, University of Toronto

Lecture Query evaluation. Cost-based transformations. By Marina Barsky Winter 2016, University of Toronto Lecture 02.04. Query evaluation Cost-based transformations By Marina Barsky Winter 2016, University of Toronto RDBMS query evaluation How does a RDBMS answer your query? SQL Query Relational Algebra (RA)

More information

Query Optimization. Introduction to Databases CompSci 316 Fall 2018

Query Optimization. Introduction to Databases CompSci 316 Fall 2018 Query Optimization Introduction to Databases CompSci 316 Fall 2018 2 Announcements (Tue., Nov. 20) Homework #4 due next in 2½ weeks No class this Thu. (Thanksgiving break) No weekly progress update due

More information

Advances in Data Management Query Processing and Query Optimisation A.Poulovassilis

Advances in Data Management Query Processing and Query Optimisation A.Poulovassilis 1 Advances in Data Management Query Processing and Query Optimisation A.Poulovassilis 1 General approach to the implementation of Query Processing and Query Optimisation functionalities in DBMSs 1. Parse

More information

The query processor turns user queries and data modification commands into a query plan - a sequence of operations (or algorithm) on the database

The query processor turns user queries and data modification commands into a query plan - a sequence of operations (or algorithm) on the database query processing Query Processing The query processor turns user queries and data modification commands into a query plan - a sequence of operations (or algorithm) on the database from high level queries

More information

CSIT5300: Advanced Database Systems

CSIT5300: Advanced Database Systems CSIT5300: Advanced Database Systems L10: Query Processing Other Operations, Pipelining and Materialization Dr. Kenneth LEUNG Department of Computer Science and Engineering The Hong Kong University of Science

More information

Chapter 6 Part I The Relational Algebra and Calculus

Chapter 6 Part I The Relational Algebra and Calculus Chapter 6 Part I The Relational Algebra and Calculus Copyright 2004 Ramez Elmasri and Shamkant Navathe Database State for COMPANY All examples discussed below refer to the COMPANY database shown here.

More information

Query Processing and Optimization

Query Processing and Optimization Query Processing and Optimization (Part-1) Prof Monika Shah Overview of Query Execution SQL Query Compile Optimize Execute SQL query parse parse tree statistics convert logical query plan apply laws improved

More information

Chapter 14: Query Optimization

Chapter 14: Query Optimization Chapter 14: Query Optimization Database System Concepts 5 th Ed. See www.db-book.com for conditions on re-use Chapter 14: Query Optimization Introduction Transformation of Relational Expressions Catalog

More information

Database Tuning and Physical Design: Basics of Query Execution

Database Tuning and Physical Design: Basics of Query Execution Database Tuning and Physical Design: Basics of Query Execution Spring 2018 School of Computer Science University of Waterloo Databases CS348 (University of Waterloo) Query Execution 1 / 43 The Client/Server

More information

The Extended Algebra. Duplicate Elimination. Sorting. Example: Duplicate Elimination

The Extended Algebra. Duplicate Elimination. Sorting. Example: Duplicate Elimination The Extended Algebra Duplicate Elimination 2 δ = eliminate duplicates from bags. τ = sort tuples. γ = grouping and aggregation. Outerjoin : avoids dangling tuples = tuples that do not join with anything.

More information

CSE 544 Principles of Database Management Systems

CSE 544 Principles of Database Management Systems CSE 544 Principles of Database Management Systems Alvin Cheung Fall 2015 Lecture 6 Lifecycle of a Query Plan 1 Announcements HW1 is due Thursday Projects proposals are due on Wednesday Office hour canceled

More information

Relational Model, Relational Algebra, and SQL

Relational Model, Relational Algebra, and SQL Relational Model, Relational Algebra, and SQL August 29, 2007 1 Relational Model Data model. constraints. Set of conceptual tools for describing of data, data semantics, data relationships, and data integrity

More information

Query Execution [15]

Query Execution [15] CSC 661, Principles of Database Systems Query Execution [15] Dr. Kalpakis http://www.csee.umbc.edu/~kalpakis/courses/661 Query processing involves Query processing compilation parsing to construct parse

More information

Contents Contents Introduction Basic Steps in Query Processing Introduction Transformation of Relational Expressions...

Contents Contents Introduction Basic Steps in Query Processing Introduction Transformation of Relational Expressions... Contents Contents...283 Introduction...283 Basic Steps in Query Processing...284 Introduction...285 Transformation of Relational Expressions...287 Equivalence Rules...289 Transformation Example: Pushing

More information

Advanced Database Systems

Advanced Database Systems Lecture IV Query Processing Kyumars Sheykh Esmaili Basic Steps in Query Processing 2 Query Optimization Many equivalent execution plans Choosing the best one Based on Heuristics, Cost Will be discussed

More information

QUERY PROCESSING & OPTIMIZATION CHAPTER 19 (6/E) CHAPTER 15 (5/E)

QUERY PROCESSING & OPTIMIZATION CHAPTER 19 (6/E) CHAPTER 15 (5/E) QUERY PROCESSING & OPTIMIZATION CHAPTER 19 (6/E) CHAPTER 15 (5/E) 2 LECTURE OUTLINE Query Processing Methodology Basic Operations and Their Costs Generation of Execution Plans 3 QUERY PROCESSING IN A DDBMS

More information

Relational Query Optimization. Overview of Query Evaluation. SQL Refresher. Yanlei Diao UMass Amherst October 23 & 25, 2007

Relational Query Optimization. Overview of Query Evaluation. SQL Refresher. Yanlei Diao UMass Amherst October 23 & 25, 2007 Relational Query Optimization Yanlei Diao UMass Amherst October 23 & 25, 2007 Slide Content Courtesy of R. Ramakrishnan, J. Gehrke, and J. Hellerstein 1 Overview of Query Evaluation Query Evaluation Plan:

More information

CS 245 Midterm Exam Solution Winter 2015

CS 245 Midterm Exam Solution Winter 2015 CS 245 Midterm Exam Solution Winter 2015 This exam is open book and notes. You can use a calculator and your laptop to access course notes and videos (but not to communicate with other people). You have

More information

Implementation of Relational Operations

Implementation of Relational Operations Implementation of Relational Operations Module 4, Lecture 1 Database Management Systems, R. Ramakrishnan 1 Relational Operations We will consider how to implement: Selection ( ) Selects a subset of rows

More information

Informationslogistik Unit 4: The Relational Algebra

Informationslogistik Unit 4: The Relational Algebra Informationslogistik Unit 4: The Relational Algebra 26. III. 2012 Outline 1 SQL 2 Summary What happened so far? 3 The Relational Algebra Summary 4 The Relational Calculus Outline 1 SQL 2 Summary What happened

More information

Query Processing with Indexes. Announcements (February 24) Review. CPS 216 Advanced Database Systems

Query Processing with Indexes. Announcements (February 24) Review. CPS 216 Advanced Database Systems Query Processing with Indexes CPS 216 Advanced Database Systems Announcements (February 24) 2 More reading assignment for next week Buffer management (due next Wednesday) Homework #2 due next Thursday

More information

Query processing and optimization

Query processing and optimization Query processing and optimization These slides are a modified version of the slides of the book Database System Concepts (Chapter 13 and 14), 5th Ed., McGraw-Hill, by Silberschatz, Korth and Sudarshan.

More information

Schema for Examples. Query Optimization. Alternative Plans 1 (No Indexes) Motivating Example. Alternative Plans 2 With Indexes

Schema for Examples. Query Optimization. Alternative Plans 1 (No Indexes) Motivating Example. Alternative Plans 2 With Indexes Schema for Examples Query Optimization (sid: integer, : string, rating: integer, age: real) (sid: integer, bid: integer, day: dates, rname: string) Similar to old schema; rname added for variations. :

More information

CompSci 516 Data Intensive Computing Systems. Lecture 11. Query Optimization. Instructor: Sudeepa Roy

CompSci 516 Data Intensive Computing Systems. Lecture 11. Query Optimization. Instructor: Sudeepa Roy CompSci 516 Data Intensive Computing Systems Lecture 11 Query Optimization Instructor: Sudeepa Roy Duke CS, Fall 2017 CompSci 516: Database Systems 1 Announcements HW2 has been posted on sakai Due on Oct

More information

CSE 344 APRIL 20 TH RDBMS INTERNALS

CSE 344 APRIL 20 TH RDBMS INTERNALS CSE 344 APRIL 20 TH RDBMS INTERNALS ADMINISTRIVIA OQ5 Out Datalog Due next Wednesday HW4 Due next Wednesday Written portion (.pdf) Coding portion (one.dl file) TODAY Back to RDBMS Query plans and DBMS

More information

Evaluation of Relational Operations. Relational Operations

Evaluation of Relational Operations. Relational Operations Evaluation of Relational Operations Chapter 14, Part A (Joins) Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Relational Operations v We will consider how to implement: Selection ( )

More information

Evaluation of Relational Operations

Evaluation of Relational Operations Evaluation of Relational Operations Chapter 14 Comp 521 Files and Databases Fall 2010 1 Relational Operations We will consider in more detail how to implement: Selection ( ) Selects a subset of rows from

More information

Relational Query Optimization

Relational Query Optimization Relational Query Optimization Module 4, Lectures 3 and 4 Database Management Systems, R. Ramakrishnan 1 Overview of Query Optimization Plan: Tree of R.A. ops, with choice of alg for each op. Each operator

More information

Evaluating Queries. Query Processing: Overview. Query Processing: Example 6/2/2009. Query Processing

Evaluating Queries. Query Processing: Overview. Query Processing: Example 6/2/2009. Query Processing Evaluating Queries Query Processing Query Processing: Overview Query Processing: Example select lname from employee where ssn = 123456789 ; query expression tree? π lname σ ssn= 123456789 employee physical

More information

Ch 5 : Query Processing & Optimization

Ch 5 : Query Processing & Optimization Ch 5 : Query Processing & Optimization Basic Steps in Query Processing 1. Parsing and translation 2. Optimization 3. Evaluation Basic Steps in Query Processing (Cont.) Parsing and translation translate

More information

Transactions and Concurrency Control

Transactions and Concurrency Control Transactions and Concurrency Control Transaction: a unit of program execution that accesses and possibly updates some data items. A transaction is a collection of operations that logically form a single

More information

What s a database system? Review of Basic Database Concepts. Entity-relationship (E/R) diagram. Two important questions. Physical data independence

What s a database system? Review of Basic Database Concepts. Entity-relationship (E/R) diagram. Two important questions. Physical data independence What s a database system? Review of Basic Database Concepts CPS 296.1 Topics in Database Systems According to Oxford Dictionary Database: an organized body of related information Database system, DataBase

More information

Query Optimization. Schema for Examples. Motivating Example. Similar to old schema; rname added for variations. Reserves: Sailors:

Query Optimization. Schema for Examples. Motivating Example. Similar to old schema; rname added for variations. Reserves: Sailors: Query Optimization Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Schema for Examples (sid: integer, sname: string, rating: integer, age: real) (sid: integer, bid: integer, day: dates,

More information

CSE 544 Principles of Database Management Systems. Magdalena Balazinska Fall 2007 Lecture 7 - Query execution

CSE 544 Principles of Database Management Systems. Magdalena Balazinska Fall 2007 Lecture 7 - Query execution CSE 544 Principles of Database Management Systems Magdalena Balazinska Fall 2007 Lecture 7 - Query execution References Generalized Search Trees for Database Systems. J. M. Hellerstein, J. F. Naughton

More information

Announcements. Two typical kinds of queries. Choosing Index is Not Enough. Cost Parameters. Cost of Reading Data From Disk

Announcements. Two typical kinds of queries. Choosing Index is Not Enough. Cost Parameters. Cost of Reading Data From Disk Announcements Introduction to Database Systems CSE 414 Lecture 17: Basics of Query Optimization and Query Cost Estimation Midterm will be released by end of day today Need to start one HW6 step NOW: https://aws.amazon.com/education/awseducate/apply/

More information

Something to think about. Problems. Purpose. Vocabulary. Query Evaluation Techniques for large DB. Part 1. Fact:

Something to think about. Problems. Purpose. Vocabulary. Query Evaluation Techniques for large DB. Part 1. Fact: Query Evaluation Techniques for large DB Part 1 Fact: While data base management systems are standard tools in business data processing they are slowly being introduced to all the other emerging data base

More information

Relational Algebra Equivalencies. Database Systems: The Complete Book Ch

Relational Algebra Equivalencies. Database Systems: The Complete Book Ch elational Algebra Equivalencies Database ystems: he Complete Book Ch. 16.2-16.3 Implementing: Joins olution 1 (Nested-Loop) For Each (a in A) { For Each (b in B) { emit (a, b); }} A B 2 Implementing: Joins

More information

Introduction Alternative ways of evaluating a given query using

Introduction Alternative ways of evaluating a given query using Query Optimization Introduction Catalog Information for Cost Estimation Estimation of Statistics Transformation of Relational Expressions Dynamic Programming for Choosing Evaluation Plans Introduction

More information

Chapter 11: Query Optimization

Chapter 11: Query Optimization Chapter 11: Query Optimization Chapter 11: Query Optimization Introduction Transformation of Relational Expressions Statistical Information for Cost Estimation Cost-based optimization Dynamic Programming

More information

Optimization Overview

Optimization Overview Lecture 17 Optimization Overview Lecture 17 Lecture 17 Today s Lecture 1. Logical Optimization 2. Physical Optimization 3. Course Summary 2 Lecture 17 Logical vs. Physical Optimization Logical optimization:

More information

Overview of Implementing Relational Operators and Query Evaluation

Overview of Implementing Relational Operators and Query Evaluation Overview of Implementing Relational Operators and Query Evaluation Chapter 12 Motivation: Evaluating Queries The same query can be evaluated in different ways. The evaluation strategy (plan) can make orders

More information

Principles of Data Management. Lecture #12 (Query Optimization I)

Principles of Data Management. Lecture #12 (Query Optimization I) Principles of Data Management Lecture #12 (Query Optimization I) Instructor: Mike Carey mjcarey@ics.uci.edu Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Today s Notable News v B+ tree

More information

Chapter 19 Query Optimization

Chapter 19 Query Optimization Chapter 19 Query Optimization It is an activity conducted by the query optimizer to select the best available strategy for executing the query. 1. Query Trees and Heuristics for Query Optimization - Apply

More information

Review: Query Evaluation Steps. Example Query: Logical Plan 1. What We Already Know. Example Query: Logical Plan 2.

Review: Query Evaluation Steps. Example Query: Logical Plan 1. What We Already Know. Example Query: Logical Plan 2. Review: Query Evaluation Steps CSE 444: Database Internals SQL query Parse & Rewrite Query Lecture 10 Query Optimization (part 1) Query optimization Select Logical Plan Select Physical Plan Query Execution

More information

Relational Query Optimization

Relational Query Optimization Relational Query Optimization Chapter 15 Ramakrishnan & Gehrke (Sections 15.1-15.6) CPSC404, Laks V.S. Lakshmanan 1 What you will learn from this lecture Cost-based query optimization (System R) Plan space

More information

Advanced Databases. Lecture 4 - Query Optimization. Masood Niazi Torshiz Islamic Azad university- Mashhad Branch

Advanced Databases. Lecture 4 - Query Optimization. Masood Niazi Torshiz Islamic Azad university- Mashhad Branch Advanced Databases Lecture 4 - Query Optimization Masood Niazi Torshiz Islamic Azad university- Mashhad Branch www.mniazi.ir Query Optimization Introduction Transformation of Relational Expressions Catalog

More information