Announcements. From SQL to RA. Query Evaluation Steps. An Equivalent Expression

Size: px
Start display at page:

Download "Announcements. From SQL to RA. Query Evaluation Steps. An Equivalent Expression"

Transcription

1 Announcements Introduction to Data Management CSE 344 Webquiz 3 is due tomorrow Lectures 9: Relational Algebra (part 2) and Query Evaluation 1 2 Query Evaluation Steps Translate query string into internal representation Logical plan à physical plan SQL query Parse & Check Query Decide how best to answer query: query optimization Query Execution Return Results Check syntax, access control, table names, etc. Query Evaluation 3 Product(pid, name, price) Purchase(pid, cid, store) Customer(cid, name, city) From SQL to RA SELECT DISTINCT x.name, z.name FROM Product x, Purchase y, Customer z WHERE x.pid = y.pid and y.cid = y.cid and x.price > 100 and z.city = Seattle 4 Product(pid, name, price) Purchase(pid, cid, store) Customer(cid, name, city) From SQL to RA SELECT DISTINCT x.name, z.name FROM Product x, Purchase y, Customer z δ WHERE x.pid = y.pid and y.cid = y.cid and x.price > 100 and z.city = Seattle Π x.name,z.name An Equivalent Expression Query optimization = finding cheaper, equivalent expressions SELECT DISTINCT x.name, z.name FROM Product x, Purchase y, Customer z δ WHERE x.pid = y.pid and y.cid = y.cid and x.price > 100 and z.city = Seattle Π x.name,z.name σ price>100 and city= Seattle cid=cid Product pid=pid Purchase cid=cid Customer 5 pid=pid σ price>100 Product Purchase σ city= Seattle Customer 6 1

2 Extended RA: Operators on Bags Duplicate elimination δ Grouping γ Sorting τ Logical Query Plan SELECT city, count(*) FROM sales GROUP BY city HAVING sum(price) > 100 Π city, c σ p > 100 T3(city, c) T2(city,p,c) T1(city,p,c) γ city, sum(price) p, count(*) c T1, T2, T3 = temporary tables sales(product, city, price) 7 8 Typical Plan for Block (1/2)... Typical Plan For Block (2/2) having condition π fields γ fields, sum/count/min/max(fields) σ selection condition join condition SELECT-PROJECT-JOIN Query π fields σ selection condition join condition join condition R S 9 10 (sno,sname,scity,sstate) How about Subqueries? (sno,sname,scity,sstate) How about Subqueries? and not exists (SELECT * WHERE P.sno = Q.sno and P.price > 100) and not exists (SELECT * WHERE P.sno = Q.sno and P.price > 100) Correlation!

3 How about Subqueries? and not exists (SELECT * WHERE P.sno = Q.sno and P.price > 100) (sno,sname,scity,sstate) De-Correlation and Q.sno not in (SELECT P.sno WHERE P.price > 100) 13 How about Subqueries? ( ) EXCEPT (SELECT P.sno WHERE P.price > 100) EXCEPT = set difference Un-nesting (sno,sname,scity,sstate) and Q.sno not in (SELECT P.sno WHERE P.price > 100) 14 (sno,sname,scity,sstate) How about Subqueries? ( ) EXCEPT (SELECT P.sno WHERE P.price > 100) Finally π sno σ sstate= WA π sno σ Price > 100 From Logical Plans to Physical Plans Query Evaluation Steps Review SQL query (sid, sname, scity, sstate) Example Query optimization Parse & Rewrite Query Select Logical Plan Select Physical Plan Query Execution Logical plan Physical plan Give a relational algebra expression for this query Disk

4 (sid, sname, scity, sstate) Relational Algebra (σ scity= Seattle sstate= WA pno=2 ( sid = sid )) (sid, sname, scity, sstate) Relational algebra expression is also called the logical query plan Relational Algebra σ scity= Seattle sstate= WA pno=2 sid = sid (sid, sname, scity, sstate) Physical Query Plan 1 σ scity= Seattle sstate= WA pno=2 (Nested loop) sid = sid A physical query plan is a logical query plan annotated with physical implementation details 21 (sid, sname, scity, sstate) Physical Query Plan 2 σ scity= Seattle sstate= WA pno=2 (Hash join) sid = sid Same logical query plan Different physical plan 22 (sid, sname, scity, sstate) (Sort-merge join) (Scan & write to T1) Physical Query Plan 3 sid = sid (a) σ scity= Seattle sstate= WA (d) (c) Different but equivalent logical query plan; different physical plan (b) σ pno=2 (Scan & write to T2) Query Optimization Problem For each SQL query many logical plans For each logical plan many physical plans How do find a fast physical plan? Will discuss in a few lectures

5 Demonstration with SQL Server Management Studio Query Execution Iterator Interface Initializes operator state Sets parameters such as selection condition Operator invokes get_ recursively on its inputs Performs processing and produces an output tuple close(): clean-up state Pipelined Query Execution (Nested loop) σ sscity= Seattle sstate= WA pno=2 s sno = sno 27 Supplies 28 Pipelined Query Execution (Nested loop) σ sscity= Seattle sstate= WA pno=2 s sno = sno nex() Supplies 29 Pipelined Execution Tuples generated by an operator are immediately sent to the parent Benefits: No operator synchronization issues No need to buffer tuples between operators Saves cost of writing intermediate data to disk Saves cost of reading intermediate data from disk This approach is used whenever possible 30 5

6 Intermediate Tuple Materialization Tuples generated by an operator are written to disk an in intermediate table No direct benefit Necessary: For certain operator implementations When we don t have enough memory Intermediate Tuple Materialization (Sort-merge join) (Scan: write to T1) s sno = sno σ sscity= Seattle sstate= WA 31 σ pno=2 Supplies (Scan: write to T2) 32 Query Execution Bottom Line SQL query transformed into physical plan Access path selection for each relation Scan the relation or use an index (see next lecture) Implementation choice for each operator Nested loop join, hash join, etc. Scheduling decisions for operators Pipelined execution or intermediate materialization Execution of the physical plan is pull-based Physical Data Independence Means that applications are insulated from changes in physical storage details E.g., can add/remove indexes without changing apps Can do other physical tunings for performance SQL and relational algebra facilitate physical data independence because both languages are set-at-a-time : Relations as input and output Database Management System Deployments Architectures 1. Serverless 2. Two tier: client/server 3. Three tier: client/app-server/db-server

7 Desktop DBMS Application (SQLite) Serverless User SQLite: One data file One user One DBMS application But only a limited number of scenarios work with such model Client Applications File Data file Disk Client Applications Server Machine Client Applications Connection (JDBC, ODBC) Connection (JDBC, ODBC) 39 One server running the database Many clients, connecting via the ODBC or JDBC (Java Database Connectivity) protocol 40 Server Machine Supports many apps and many users simultaneously Client Applications Connection (JDBC, ODBC) One server that runs the DBMS (or RDBMS): Your own desktop, or Some beefy system, or A cloud service (SQL Azure) One server running the database Many clients, connecting via the ODBC or JDBC (Java Database Connectivity) protocol

8 One server that runs the DBMS (or RDBMS): Your own desktop, or Some beefy system, or A cloud service (SQL Azure) Many clients run apps and connect to DBMS Microsoft s Management Studio (for SQL Server), or psql (for postgres) Some Java program (HW7) or some C++ program One server that runs the DBMS (or RDBMS): Your own desktop, or Some beefy system, or A cloud service (SQL Azure) Many clients run apps and connect to DBMS Microsoft s Management Studio (for SQL Server), or psql (for postgres) Some Java program (HW5) or some C++ program Clients talk to server using JDBC/ODBC protocol Tiers DBMS Deployment Browser 3-Tiers DBMS Deployment Browser Connection (e.g., JDBC) Tiers DBMS Deployment Browser 3-Tiers DBMS Deployment Connection (e.g., JDBC) Connection (e.g., JDBC) Web-based applications

9 Replicate 3-Tiers App DBMS server Deployment for scaleup DBMS Deployment: Cloud Easy scaleup, scaledown Users Why don t we replicate the DB server too? Connection (e.g., JDBC) Developers 49 Web & App Server 50 Using a DBMS Server 1. Client application establishes connection to server 2. Client must authenticate self 3. Client submits SQL commands to server 4. Server executes commands and returns results 51 9

Introduction to Data Management CSE 344. Lectures 9: Relational Algebra (part 2) and Query Evaluation

Introduction to Data Management CSE 344. Lectures 9: Relational Algebra (part 2) and Query Evaluation Introduction to Data Management CSE 344 Lectures 9: Relational Algebra (part 2) and Query Evaluation 1 Announcements Webquiz 3 is due tomorrow 2 Query Evaluation Steps SQL query Translate query string

More information

Introduction to Database Systems CSE 444

Introduction to Database Systems CSE 444 Introduction to Database Systems CSE 444 Lecture 18: Query Processing Overview CSE 444 - Summer 2010 1 Where We Are We are learning how a DBMS executes a query How come a DBMS can execute a query so fast?

More information

Agenda. Discussion. Database/Relation/Tuple. Schema. Instance. CSE 444: Database Internals. Review Relational Model

Agenda. Discussion. Database/Relation/Tuple. Schema. Instance. CSE 444: Database Internals. Review Relational Model Agenda CSE 444: Database Internals Review Relational Model Lecture 2 Review of the Relational Model Review Queries (will skip most slides) Relational Algebra SQL Review translation SQL à RA Needed for

More information

Announcements. Agenda. Database/Relation/Tuple. Discussion. Schema. CSE 444: Database Internals. Room change: Lab 1 part 1 is due on Monday

Announcements. Agenda. Database/Relation/Tuple. Discussion. Schema. CSE 444: Database Internals. Room change: Lab 1 part 1 is due on Monday Announcements CSE 444: Database Internals Lecture 2 Review of the Relational Model Room change: Gowen (GWN) 301 on Monday, Friday Fisheries (FSH) 102 on Wednesday Lab 1 part 1 is due on Monday HW1 is due

More information

Announcements. Agenda. Database/Relation/Tuple. Schema. Discussion. CSE 444: Database Internals

Announcements. Agenda. Database/Relation/Tuple. Schema. Discussion. CSE 444: Database Internals Announcements CSE 444: Database Internals Lecture 2 Review of the Relational Model Lab 1 part 1 is due on Friday Lab 1 is due next week on Friday git commit a and git push often! HW1 is due on Wednesday,

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

Lecture 17: Query execution. Wednesday, May 12, 2010

Lecture 17: Query execution. Wednesday, May 12, 2010 Lecture 17: Query execution Wednesday, May 12, 2010 1 Outline of Next Few Lectures Query execution Query optimization 2 Steps of the Query Processor SQL query Parse & Rewrite Query Query optimization Select

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

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

CSE 344 JANUARY 26 TH DATALOG

CSE 344 JANUARY 26 TH DATALOG CSE 344 JANUARY 26 TH DATALOG ADMINISTRATIVE MINUTIAE HW3 and OQ3 out HW3 due next Friday OQ3 due next Wednesday HW4 out next week: on Datalog Midterm reminder: Feb 9 th RELATIONAL ALGEBRA Set-at-a-time

More information

Introduction to Database Systems CSE 414. Lecture 16: Query Evaluation

Introduction to Database Systems CSE 414. Lecture 16: Query Evaluation Introduction to Database Systems CSE 414 Lecture 16: Query Evaluation CSE 414 - Spring 2018 1 Announcements HW5 + WQ5 due tomorrow Midterm this Friday in class! Review session this Wednesday evening See

More information

CSEP 544: Lecture 04. Query Execution. CSEP544 - Fall

CSEP 544: Lecture 04. Query Execution. CSEP544 - Fall CSEP 544: Lecture 04 Query Execution CSEP544 - Fall 2015 1 Announcements Homework 2: due on Friday Homework 3: We use AWS You need to get an access code: https://aws.amazon.com/education/ awseducate/members/

More information

CSE 344 FEBRUARY 14 TH INDEXING

CSE 344 FEBRUARY 14 TH INDEXING CSE 344 FEBRUARY 14 TH INDEXING EXAM Grades posted to Canvas Exams handed back in section tomorrow Regrades: Friday office hours EXAM Overall, you did well Average: 79 Remember: lowest between midterm/final

More information

CSE 444: Database Internals. Lecture 3 DBMS Architecture

CSE 444: Database Internals. Lecture 3 DBMS Architecture CSE 444: Database Internals Lecture 3 DBMS Architecture 1 Announcements On Wednesdays lecture will be in FSH 102 Lab 1 part 1 due tonight at 11pm Turn in using script in local repo:./turninlab.sh lab1-part1

More information

CSE 444: Database Internals. Lecture 3 DBMS Architecture

CSE 444: Database Internals. Lecture 3 DBMS Architecture CSE 444: Database Internals Lecture 3 DBMS Architecture CSE 444 - Spring 2016 1 Upcoming Deadlines Lab 1 Part 1 is due today at 11pm Go through logistics of getting started Start to make some small changes

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

Introduction to Data Management CSE 344. Lecture 12: Cost Estimation Relational Calculus

Introduction to Data Management CSE 344. Lecture 12: Cost Estimation Relational Calculus Introduction to Data Management CSE 344 Lecture 12: Cost Estimation Relational Calculus CSE 344 - Winter 2017 1 HW3 due tonight Announcements WQ4 and HW4 out Due on Thursday 2/9 2 Midterm! Monday, February

More information

Database Systems CSE 414

Database Systems CSE 414 Database Systems CSE 414 Lectures 16 17: Basics of Query Optimization and Cost Estimation (Ch. 15.{1,3,4.6,6} & 16.4-5) 1 Announcements WQ4 is due Friday 11pm HW3 is due next Tuesday 11pm Midterm is next

More information

10/18/2017. Announcements. NoSQL Motivation. NoSQL. Serverless Architecture. What is the Problem? Database Systems CSE 414

10/18/2017. Announcements. NoSQL Motivation. NoSQL. Serverless Architecture. What is the Problem? Database Systems CSE 414 Announcements Database Systems CSE 414 Lecture 11: NoSQL & JSON (mostly not in textbook only Ch 11.1) HW5 will be posted on Friday and due on Nov. 14, 11pm [No Web Quiz 5] Today s lecture: NoSQL & JSON

More information

5/2/16. Announcements. NoSQL Motivation. The New Hipster: NoSQL. Serverless. What is the Problem? Database Systems CSE 414

5/2/16. Announcements. NoSQL Motivation. The New Hipster: NoSQL. Serverless. What is the Problem? Database Systems CSE 414 Announcements Database Systems CSE 414 Lecture 16: NoSQL and JSon Current assignments: Homework 4 due tonight Web Quiz 6 due next Wednesday [There is no Web Quiz 5 Today s lecture: JSon The book covers

More information

Database Systems CSE 414

Database Systems CSE 414 Database Systems CSE 414 Lecture 16: NoSQL and JSon CSE 414 - Spring 2016 1 Announcements Current assignments: Homework 4 due tonight Web Quiz 6 due next Wednesday [There is no Web Quiz 5] Today s lecture:

More information

CSE 444: Database Internals. Lectures 5-6 Indexing

CSE 444: Database Internals. Lectures 5-6 Indexing CSE 444: Database Internals Lectures 5-6 Indexing 1 Announcements HW1 due tonight by 11pm Turn in an electronic copy (word/pdf) by 11pm, or Turn in a hard copy in my office by 4pm Lab1 is due Friday, 11pm

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

Class Overview. Two Classes of Database Applications. NoSQL Motivation. RDBMS Review: Client-Server. RDBMS Review: Serverless

Class Overview. Two Classes of Database Applications. NoSQL Motivation. RDBMS Review: Client-Server. RDBMS Review: Serverless Introduction to Database Systems CSE 414 Lecture 12: NoSQL 1 Class Overview Unit 1: Intro Unit 2: Relational Data Models and Query Languages Unit 3: Non-relational data NoSQL Json SQL++ Unit 4: RDMBS internals

More information

Announcements. Two Classes of Database Applications. Class Overview. NoSQL Motivation. RDBMS Review: Serverless

Announcements. Two Classes of Database Applications. Class Overview. NoSQL Motivation. RDBMS Review: Serverless Introduction to Database Systems CSE 414 Lecture 11: NoSQL 1 HW 3 due Friday Announcements Upload data with DataGrip editor see message board Azure timeout for question 5: Try DataGrip or SQLite HW 2 Grades

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

5/1/17. Announcements. NoSQL Motivation. NoSQL. Serverless Architecture. What is the Problem? Database Systems CSE 414

5/1/17. Announcements. NoSQL Motivation. NoSQL. Serverless Architecture. What is the Problem? Database Systems CSE 414 Announcements Database Systems CSE 414 Lecture 15: NoSQL & JSON (mostly not in textbook only Ch 11.1) 1 Homework 4 due tomorrow night [No Web Quiz 5] Midterm grading hopefully finished tonight post online

More information

CSE 344 JULY 9 TH NOSQL

CSE 344 JULY 9 TH NOSQL CSE 344 JULY 9 TH NOSQL ADMINISTRATIVE MINUTIAE HW3 due Wednesday tests released actual_time should have 0s not NULLs upload new data file or use UPDATE to change 0 ~> NULL Extra OOs on Mondays 5-7pm in

More information

Introduction to Database Systems CSE 344

Introduction to Database Systems CSE 344 Introduction to Database Systems CSE 344 Lecture 10: Basics of Data Storage and Indexes 1 Reminder HW3 is due next Wednesday 2 Review Logical plans Physical plans Overview of query optimization and execution

More information

Database Management Systems CSEP 544. Lecture 3: SQL Relational Algebra, and Datalog

Database Management Systems CSEP 544. Lecture 3: SQL Relational Algebra, and Datalog Database Management Systems CSEP 544 Lecture 3: SQL Relational Algebra, and Datalog CSEP 544 - Fall 2017 1 Announcements HW2 due tonight (11:59pm) PA3 & HW3 released CSEP 544 - Fall 2017 2 HW3 We will

More information

Lecture 19: Query Optimization (1)

Lecture 19: Query Optimization (1) Lecture 19: Query Optimization (1) May 17, 2010 Dan Suciu -- 444 Spring 2010 1 Announcements Homework 3 due on Wednesday in class How is it going? Project 4 posted Due on June 2 nd Start early! Dan Suciu

More information

CSE 544 Principles of Database Management Systems

CSE 544 Principles of Database Management Systems CSE 544 Principles of Database Management Systems Magdalena Balazinska Winter 2015 Lecture 2 SQL and Schema Normalization 1 Announcements Paper review First paper review is due before lecture on Wednesday

More information

CSE 344 APRIL 27 TH COST ESTIMATION

CSE 344 APRIL 27 TH COST ESTIMATION CSE 344 APRIL 27 TH COST ESTIMATION ADMINISTRIVIA HW5 Out Please verify that you can run queries Midterm May 9 th 9:30-10:20 MLR 301 Review (in class) May 7th Practice exam May 4 th Through parallelism:

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

What we already know. Late Days. CSE 444: Database Internals. Lecture 3 DBMS Architecture

What we already know. Late Days. CSE 444: Database Internals. Lecture 3 DBMS Architecture CSE 444: Database Internals Lecture 3 1 Announcements On Wednesdays lecture will be in FSH 102 Lab 1 part 1 due tonight at 11pm Turn in using script in local repo:./turninlab.sh lab1-part1 Remember to

More information

Data Storage. Query Performance. Index. Data File Types. Introduction to Data Management CSE 414. Introduction to Database Systems CSE 414

Data Storage. Query Performance. Index. Data File Types. Introduction to Data Management CSE 414. Introduction to Database Systems CSE 414 Introduction to Data Management CSE 414 Unit 4: RDBMS Internals Logical and Physical Plans Query Execution Query Optimization Introduction to Database Systems CSE 414 Lecture 16: Basics of Data Storage

More information

CSE 344 FEBRUARY 21 ST COST ESTIMATION

CSE 344 FEBRUARY 21 ST COST ESTIMATION CSE 344 FEBRUARY 21 ST COST ESTIMATION ADMINISTRIVIA HW5 Due Tonight (11:30) OQ5 Due Friday (11:00) HW6 Due next Wednesday (Feb 28) HW7 Out Friday Entity Relations Due TBD HW8 Out Monday Due Mar 9 th BASIC

More information

Lassonde School of Engineering Winter 2016 Term Course No: 4411 Database Management Systems

Lassonde School of Engineering Winter 2016 Term Course No: 4411 Database Management Systems Lassonde School of Engineering Winter 2016 Term Course No: 4411 Database Management Systems Last Name: First Name: Student ID: 1. Exam is 2 hours long 2. Closed books/notes Problem 1 (6 points) Consider

More information

Database Systems CSE 414

Database Systems CSE 414 Database Systems CSE 414 Lecture 6: Nested Queries in SQL 1 Announcements WQ2 is due on Sunday 11pm no late days HW2 is due on Tuesday 11pm 2 Lecture Goals Today we will learn how to write (even) more

More information

Review. Administrivia (Preview for Friday) Lecture 21: Query Optimization (1) Where We Are. Relational Algebra. Relational Algebra.

Review. Administrivia (Preview for Friday) Lecture 21: Query Optimization (1) Where We Are. Relational Algebra. Relational Algebra. Administrivia (Preview for Friday) Lecture 21: Query Optimization (1) November 17, 2010 For project 4, students are expected (but not required) to work in pairs. Ideally you should pair up by end of day

More information

Announcements. Subqueries. Lecture Goals. 1. Subqueries in SELECT. Database Systems CSE 414. HW1 is due today 11pm. WQ1 is due tomorrow 11pm

Announcements. Subqueries. Lecture Goals. 1. Subqueries in SELECT. Database Systems CSE 414. HW1 is due today 11pm. WQ1 is due tomorrow 11pm Announcements Database Systems CSE 414 Lecture 6: Nested Queries in SQL HW1 is due today 11pm WQ1 is due tomorrow 11pm no late days WQ3 is posted and due on Oct. 19, 11pm 1 2 Lecture Goals Today we will

More information

Lecture 21: Query Optimization (1)

Lecture 21: Query Optimization (1) Lecture 21: Query Optimization (1) November 17, 2010 1 Administrivia (Preview for Friday) For project 4, students are expected (but not required) to work in pairs. Ideally you should pair up by end of

More information

Database Management Systems CSEP 544. Lecture 6: Query Execution and Optimization Parallel Data processing

Database Management Systems CSEP 544. Lecture 6: Query Execution and Optimization Parallel Data processing Database Management Systems CSEP 544 Lecture 6: Query Execution and Optimization Parallel Data processing CSEP 544 - Fall 2017 1 HW5 due today Announcements HW6 released Please start early! You need to

More information

Introduction to Database Systems CSE 414

Introduction to Database Systems CSE 414 Introduction to Database Systems CSE 414 Lecture 8: Nested Queries in SQL CSE 414 - Spring 2013 1 Announcements Homework 2 due tonight Webquiz 3 due Friday 2 questions on nested queries (i.e., today s

More information

R & G Chapter 13. Implementation of single Relational Operations Choices depend on indexes, memory, stats, Joins Blocked nested loops:

R & G Chapter 13. Implementation of single Relational Operations Choices depend on indexes, memory, stats, Joins Blocked nested loops: Relational Query Optimization R & G Chapter 13 Review Implementation of single Relational Operations Choices depend on indexes, memory, stats, Joins Blocked nested loops: simple, exploits extra memory

More information

CSE 344 JANUARY 19 TH SUBQUERIES 2 AND RELATIONAL ALGEBRA

CSE 344 JANUARY 19 TH SUBQUERIES 2 AND RELATIONAL ALGEBRA CSE 344 JANUARY 19 TH SUBQUERIES 2 AND RELATIONAL ALGEBRA ASSORTED MINUTIAE Winter storm Inga Online quiz out after class Still due Wednesday, will be shorter but through today s lecture For SQLite submissions,

More information

Examples of Physical Query Plan Alternatives. Selected Material from Chapters 12, 14 and 15

Examples of Physical Query Plan Alternatives. Selected Material from Chapters 12, 14 and 15 Examples of Physical Query Plan Alternatives Selected Material from Chapters 12, 14 and 15 1 Query Optimization NOTE: SQL provides many ways to express a query. HENCE: System has many options for evaluating

More information

CSE344 Midterm Exam Fall 2016

CSE344 Midterm Exam Fall 2016 CSE344 Midterm Exam Fall 2016 November 7, 2016 Please read all instructions (including these) carefully. This is a closed book exam. You are allowed a one page handwritten cheat sheet. Write your name

More information

Database Applications (15-415)

Database Applications (15-415) Database Applications (15-415) DBMS Internals- Part VI Lecture 14, March 12, 2014 Mohammad Hammoud Today Last Session: DBMS Internals- Part V Hash-based indexes (Cont d) and External Sorting Today s Session:

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 2 SQL and Schema Normalization 1 Announcements Paper review First paper review is due on Wednesday 10:30am Details on website

More information

Principles of Data Management. Lecture #9 (Query Processing Overview)

Principles of Data Management. Lecture #9 (Query Processing Overview) Principles of Data Management Lecture #9 (Query Processing Overview) Instructor: Mike Carey mjcarey@ics.uci.edu Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Today s Notable News v Midterm

More information

Principles of Database Systems CSE 544. Lecture #2 SQL The Complete Story

Principles of Database Systems CSE 544. Lecture #2 SQL The Complete Story Principles of Database Systems CSE 544 Lecture #2 SQL The Complete Story CSE544 - Spring, 2013 1 Announcements Paper assignment Review was due last night Discussion on Thursday We need to schedule a makeup

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

QUERY OPTIMIZATION E Jayant Haritsa Computer Science and Automation Indian Institute of Science. JAN 2014 Slide 1 QUERY OPTIMIZATION

QUERY OPTIMIZATION E Jayant Haritsa Computer Science and Automation Indian Institute of Science. JAN 2014 Slide 1 QUERY OPTIMIZATION E0 261 Jayant Haritsa Computer Science and Automation Indian Institute of Science JAN 2014 Slide 1 Database Engines Main Components Query Processing Transaction Processing Access Methods JAN 2014 Slide

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

Introduction to Data Management CSE 344. Lectures 8: Relational Algebra

Introduction to Data Management CSE 344. Lectures 8: Relational Algebra Introduction to Data Management CSE 344 Lectures 8: Relational Algebra CSE 344 - Winter 2016 1 Announcements Homework 3 is posted Microsoft Azure Cloud services! Use the promotion code you received Due

More information

Lecture 20: Query Optimization (2)

Lecture 20: Query Optimization (2) Lecture 20: Query Optimization (2) Wednesday, May 19, 2010 1 Outline Search space Algorithms for enumerating query plans Estimating the cost of a query plan 2 Key Decisions Logical plan What logical plans

More information

CS 564 Final Exam Fall 2015 Answers

CS 564 Final Exam Fall 2015 Answers CS 564 Final Exam Fall 015 Answers A: STORAGE AND INDEXING [0pts] I. [10pts] For the following questions, clearly circle True or False. 1. The cost of a file scan is essentially the same for a heap file

More information

ECS 165B: Database System Implementa6on Lecture 7

ECS 165B: Database System Implementa6on Lecture 7 ECS 165B: Database System Implementa6on Lecture 7 UC Davis April 12, 2010 Acknowledgements: por6ons based on slides by Raghu Ramakrishnan and Johannes Gehrke. Class Agenda Last 6me: Dynamic aspects of

More information

Introduction to Database Systems CSE 414. Lecture 8: SQL Wrap-up

Introduction to Database Systems CSE 414. Lecture 8: SQL Wrap-up Introduction to Database Systems CSE 414 Lecture 8: SQL Wrap-up CSE 414 - Spring 2015 1 Announcements New web quiz out: due Monday, 11 pm A couple of questions on nested queries Homework 3 out today and

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

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

Before we talk about Big Data. Lets talk about not-so-big data

Before we talk about Big Data. Lets talk about not-so-big data Before we talk about Big Data Lets talk about not-so-big data Brief Intro to Database Systems Tova Milo, milo@cs.tau.ac.il 1 Textbook(s) Main textbook (In the library) Database Systems: The Complete Book,

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

Plan for today. Query Processing/Optimization. Parsing. A query s trip through the DBMS. Validation. Logical plan

Plan for today. Query Processing/Optimization. Parsing. A query s trip through the DBMS. Validation. Logical plan Plan for today Query Processing/Optimization CPS 216 Advanced Database Systems Overview of query processing Query execution Query plan enumeration Query rewrite heuristics Query rewrite in DB2 2 A query

More information

CSE 544: Principles of Database Systems

CSE 544: Principles of Database Systems CSE 544: Principles of Database Systems Anatomy of a DBMS, Parallel Databases 1 Announcements Lecture on Thursday, May 2nd: Moved to 9am-10:30am, CSE 403 Paper reviews: Anatomy paper was due yesterday;

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

CSE 344 Midterm Nov 1st, 2017, 1:30-2:20

CSE 344 Midterm Nov 1st, 2017, 1:30-2:20 1 SQL 1. (36 points) Acompanymaintainsadatabaseabouttheiremployeesandprojectswiththefollowing schema. Employee(eid, name, salary) Project(pid, title, budget) WorksOn(eid, pid, year) WorksOn records which

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

Query Processing and Query Optimization. Prof Monika Shah

Query Processing and Query Optimization. Prof Monika Shah Query Processing and Query Optimization Query Processing SQL Query Is in Library Cache? System catalog (Dict / Dict cache) Scan and verify relations Parse into parse tree (relational Calculus) View definitions

More information

Magda Balazinska - CSE 444, Spring

Magda Balazinska - CSE 444, Spring Query Optimization Algorithm CE 444: Database Internals Lectures 11-12 Query Optimization (part 2) Enumerate alternative plans (logical & physical) Compute estimated cost of each plan Compute number of

More information

DBMS Query evaluation

DBMS Query evaluation Data Management for Data Science DBMS Maurizio Lenzerini, Riccardo Rosati Corso di laurea magistrale in Data Science Sapienza Università di Roma Academic Year 2016/2017 http://www.dis.uniroma1.it/~rosati/dmds/

More information

Relational Query Optimization. Highlights of System R Optimizer

Relational Query Optimization. Highlights of System R Optimizer Relational Query Optimization Chapter 15 Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Highlights of System R Optimizer v Impact: Most widely used currently; works well for < 10 joins.

More information

CSE 344 MAY 7 TH EXAM REVIEW

CSE 344 MAY 7 TH EXAM REVIEW CSE 344 MAY 7 TH EXAM REVIEW EXAMINATION STATIONS Exam Wednesday 9:30-10:20 One sheet of notes, front and back Practice solutions out after class Good luck! EXAM LENGTH Production v. Verification Practice

More information

Today's Class. Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications. Example Database. Query Plan Example

Today's Class. Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications. Example Database. Query Plan Example Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications Today's Class Intro to Operator Evaluation Typical Query Optimizer Projection/Aggregation: Sort vs. Hash C. Faloutsos A. Pavlo Lecture#13:

More information

Introduction to Data Management CSE 344. Lectures 8: Relational Algebra

Introduction to Data Management CSE 344. Lectures 8: Relational Algebra Introduction to Data Management CSE 344 Lectures 8: Relational Algebra CSE 344 - Winter 2017 1 Announcements Homework 3 is posted Microsoft Azure Cloud services! Use the promotion code you received Due

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

Announcements. Database Systems CSE 414. Why compute in parallel? Big Data 10/11/2017. Two Kinds of Parallel Data Processing

Announcements. Database Systems CSE 414. Why compute in parallel? Big Data 10/11/2017. Two Kinds of Parallel Data Processing Announcements Database Systems CSE 414 HW4 is due tomorrow 11pm Lectures 18: Parallel Databases (Ch. 20.1) 1 2 Why compute in parallel? Multi-cores: Most processors have multiple cores This trend will

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

CSE 344 APRIL 11 TH DATALOG

CSE 344 APRIL 11 TH DATALOG CSE 344 APRIL 11 TH DATALOG ADMINISTRATIVE MINUTIAE HW2 Due tonight HW3 out this afternoon OQ4 Out Midterm Fill out piazza quiz before tomorrow DATALOG: FACTS AND RULES Facts = tuples in the database Rules

More information

CompSci 516 Data Intensive Computing Systems

CompSci 516 Data Intensive Computing Systems CompSci 516 Data Intensive Computing Systems Lecture 9 Join Algorithms and Query Optimizations Instructor: Sudeepa Roy CompSci 516: Data Intensive Computing Systems 1 Announcements Takeaway from Homework

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

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

COMP9311 Week 10 Lecture. DBMS Architecture. DBMS Architecture and Implementation. Database Application Performance

COMP9311 Week 10 Lecture. DBMS Architecture. DBMS Architecture and Implementation. Database Application Performance COMP9311 Week 10 Lecture DBMS Architecture DBMS Architecture and Implementation 2/51 Aims: examine techniques used in implementation of DBMSs: query processing (QP), transaction processing (TxP) use QP

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 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

Administrivia. CS 133: Databases. Cost-based Query Sub-System. Goals for Today. Midterm on Thursday 10/18. Assignments

Administrivia. CS 133: Databases. Cost-based Query Sub-System. Goals for Today. Midterm on Thursday 10/18. Assignments Administrivia Midterm on Thursday 10/18 CS 133: Databases Fall 2018 Lec 12 10/16 Prof. Beth Trushkowsky Assignments Lab 3 starts after fall break No problem set out this week Goals for Today Cost-based

More information

Query Processing & Optimization. CS 377: Database Systems

Query Processing & Optimization. CS 377: Database Systems Query Processing & Optimization CS 377: Database Systems Recap: File Organization & Indexing Physical level support for data retrieval File organization: ordered or sequential file to find items using

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

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

SQL QUERY EVALUATION. CS121: Relational Databases Fall 2017 Lecture 12

SQL QUERY EVALUATION. CS121: Relational Databases Fall 2017 Lecture 12 SQL QUERY EVALUATION CS121: Relational Databases Fall 2017 Lecture 12 Query Evaluation 2 Last time: Began looking at database implementation details How data is stored and accessed by the database Using

More information

CSE 344 Midterm Exam

CSE 344 Midterm Exam CSE 344 Midterm Exam February 9, 2015 Question 1 / 10 Question 2 / 39 Question 3 / 16 Question 4 / 28 Question 5 / 12 Total / 105 The exam is closed everything except for 1 letter-size sheet of notes.

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

Introduction to Data Management CSE 344

Introduction to Data Management CSE 344 Introduction to Data Management CSE 344 Lecture 24: MapReduce CSE 344 - Fall 2016 1 HW8 is out Last assignment! Get Amazon credits now (see instructions) Spark with Hadoop Due next wed CSE 344 - Fall 2016

More information

Overview of DB & IR. ICS 624 Spring Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa

Overview of DB & IR. ICS 624 Spring Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa ICS 624 Spring 2011 Overview of DB & IR Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 1/12/2011 Lipyeow Lim -- University of Hawaii at Manoa 1 Example

More information

Lecture 03: SQL. Friday, April 2 nd, Dan Suciu Spring

Lecture 03: SQL. Friday, April 2 nd, Dan Suciu Spring Lecture 03: SQL Friday, April 2 nd, 2010 Dan Suciu -- 444 Spring 2010 1 Announcements New IMDB database: use imdb_new instead of imdb Up to date, and much larger! Make following change to Project 1 / QuesMon

More information

Database Applications (15-415)

Database Applications (15-415) Database Applications (15-415) DBMS Internals- Part VIII Lecture 16, March 19, 2014 Mohammad Hammoud Today Last Session: DBMS Internals- Part VII Algorithms for Relational Operations (Cont d) Today s Session:

More information

CSE 544 Principles of Database Management Systems

CSE 544 Principles of Database Management Systems CSE 544 Principles of Database Management Systems Lecture 1 - Introduction and the Relational Model 1 Outline Introduction Class overview Why database management systems (DBMS)? The relational model 2

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