Optimization of Distributed Queries
|
|
- Marcus Randall
- 5 years ago
- Views:
Transcription
1 Query Optimization Optimization of Distributed Queries Issues in Query Optimization Joins and Semijoins Query Optimization Algorithms Centralized query optimization: Minimize the cots function Find (the best) query execution plan in the space of equivalent query trees Gather statistics about relations Distributed query optimization brings additional issues Linear query trees are not necessarily a good choice Bushy query trees are not necessarily a bad choice What and where to ship the relations How to ship relations (ship as a whole, ship as needed) When to use semi-joins instead of joins Spring, 2006 Arturas Mazeika Page 2 Search Space (Definition) Search Space (Reduction of the Search Space) Search space is characterized by alternative execution plans Typically the main issue is to optimize the joins For N relations, there are O(N!) (equivalent join trees that can be obtained by applying commutativity and associativity rules) Example: SELECT ENAME,RESP FROM EMP, ASG, PROJ WHERE EMP.ENO=ASG.ENO AND ASG.PNO=PROJ.PNO Restrict by means of heuristics Perform unary operations before binary operations, etc Restrict the shape of the join tree Consider the type of trees (linear trees, vs. bushy ones) Linear Join Tree Bushy Join Tree Spring, 2006 Arturas Mazeika Page 3 Spring, 2006 Arturas Mazeika Page 4
2 Search Space (Scanning the Search Space) Search Space (Scanning the Space, Example) Deterministic There are two main strategies to scan the search space Deterministic Start from base relations and build plans by adding one relation at each step Dynamic programming: breadth-first Greedy: depth-first Randomized Search for optimalities around a particular starting point Iterative improvement Trades optimization time for execution time The strategy is better when more than 5-6 relations Randomized Spring, 2006 Arturas Mazeika Page 5 Cost Functions (Strategies) Spring, 2006 Arturas Mazeika Page 6 Cost Functions (Total Time) Two different strategies can be used: Reduce total time Reduce each cost (in terms of time) component individually Do as little for each cost component as possible Optimize the utilization of the resources (increase system throughput) Reduce response time Do as many things in parallel as possible May increase total time because of increased total activity Add up all individual components: Total cost = CPU cost + I/O cost + communication cost CPU cost = unit instruction cost no. of instructions I/O cost = unit disk I/O cost no. of disk I/Os communication cost = message initiation + transmission Spring, 2006 Arturas Mazeika Page 7 Spring, 2006 Arturas Mazeika Page 8
3 Cost Functions (Total Time, Network Issues) Cost Functions (Response Time) The individual components of the total cost have different weights: Wide area network Message initiation and transmission costs high Local processing cost is low (fast mainframes or minicomputers) Ratio of communication to I/O costs is 20:1 Local area networks Communication and local processing costs are more or less equal Ratio of communication to I/O costs is 1:1.6 (10MB/s network) Definition: Elapsed time between the initiation and the completion of a query Costs: Response time = CPU time + I/O time + communication time CPU time = unit instruction time no. of sequential instructions I/O time = unit I/O time no. of sequential I/Os communication time = unit msg initiation time no. of sequential msg + unit transmission time no. of sequential bytes Spring, 2006 Arturas Mazeika Page 9 Cost Functions (Response Time, Example) Spring, 2006 Arturas Mazeika Page 10 Statistics The primary cost factor is the size of intermediate relations Assume that only the communication cost is considered Total time = 2 message initialization time + unit transmission time (x+y) Response time = max{time to send x from 1 to 3, time to send y from 2 to 3} Time to send x from 1 to 3 = message initialization time + unit transmission time x Time to send y from 2 to 3 = message initialization time + unit transmission time y It is costly to compute the intermediate relations precisely. Instead global statistics of relations and fragments are computed and used to provide approximate sizes Spring, 2006 Arturas Mazeika Page 11 Spring, 2006 Arturas Mazeika Page 12
4 Statistics (Relations and Fragments) Let R[A 1, A 2,..., A k ] be a relation fragmented into R 1, R 2,..., R r. Relation statistics min and max values of each attribute min{a i }, max{a i }. length of each attribute length(a i ) number of distinct values in each fragment (cardinality) card(a i ), (card(dom(a i ))) Fragment statistics cardinality of the fragment card(r i ) cardinality of each attribute of each fragment card(π Ai (R j )) Statistics (Selectivity) size(r) = card(r) length(r) card(σ P (R)) = SF σ (P ) card(r) Selectivity factors (with assumption of uniformality): 1 SF σ (A = value) = card(π A (R)) max(a) value SF σ (A > value) = max(a) min(a) value min(a) SF σ (A < value) = max(a) min(a) Properties of the selectivity factor of the selection SF σ (p(a i ) p(a j )) = SF σ (p(a i )) SF σ (p(a j )) SF σ (p(a i ) p(a j )) = SF σ (p(a i )) + SF σ (p(a j )) (SF σ (p(a i )) SF σ (p(a j )) SF σ (A {values}) = SF σ (A {values}) card({values}) Spring, 2006 Arturas Mazeika Page 13 Statistics (Projection, Cartesian Product, Union, Set Difference) Spring, 2006 Arturas Mazeika Page 14 Statistics (Joins) Projection Cartesian Product card(π A (R)) = card(r) card(r S) = card(r) card(s) Union upper bound: card(r S) = card(r) + card(s) lower bound: card(r S) = max{card(r), card(s)} Set Difference upper bound: card(r S) = card(r) lower bound: 0 Selectivity factor for joins: General Case: SF = card(r S) card(r) card(s) card(r S) = SF card(r) card(s) Special case: R.A is a key of R and S.A is a foreign key of S; card(r R.A=S.A S) = card(s) Spring, 2006 Arturas Mazeika Page 15 Spring, 2006 Arturas Mazeika Page 16
5 Statistics (Semijoins) Join and Semijoin Ordering Selectivity factor for semijoins General case: SF < (R < A S) = SF < (S.A) = card(π A(S)) card(dom[a]) card(r < A S) = SF < (S.A) card(r) Introduction to join ordering in fragment queries Join ordering algorithms: INGRES and distributed INGRES System R and System R Semijoin ordering Hill Climbing and SDD-1 Spring, 2006 Arturas Mazeika Page 17 Introduction to Join Ordering (Two Distributed not Fragmented Relations) Spring, 2006 Arturas Mazeika Page 18 Introduction to Join Ordering (Three Distributed not Fragmented Relations 1/2) Relations involving more that two relations are substantially more complex Consider the following example Two relations located at different sites P ROJ P NO ASG ENO EMP Move the smaller relation to the other site Spring, 2006 Arturas Mazeika Page 19 Spring, 2006 Arturas Mazeika Page 20
6 Introduction to Join Ordering (Three Distributed not Fragmented Relations 2/2) Semijoin Algorithms (Expression of Joins as Semijoins) Plan 1: EMP Site 2 Site 2: EMP =EMP ASG EMP Site 3 Site 3: EMP PROJ Plan 2: ASG Site 1 Site 1: EMP =EMP ASG EMP Site 3 Site 3: EMP PROJ Plan 3: ASG Site 3 Site 3: ASG =ASG PROJ ASG Site 1 Site 1: ASG EMP Plan 4: PROJ Site 2 Site 2: PROJ =PROJ ASG PROJ Site 1 Site 1: PROJ EMP Plan 5: EMP Site 2 PROJ Site 2 Site 2: EMP PROJ ASG Semijoins can be used to implement joins For example, consider two relations: R (located at site 1) and S (located and site 2) We have two alternatives: Do the join R S Perform one of the semijoin equivalents: R S (R < S) S R (S < R) (R < S) (S < R) Spring, 2006 Arturas Mazeika Page 21 Spring, 2006 Arturas Mazeika Page 22 Semijoin Algorithms (Transfer of Data) INGRES Centralized Algorithm (Overview) To perform the join R S: send R to Site 2 Site 2 computes R S To perform the semijoins (R < S) S: S = Π A (S) S Site 1 Site 1 computes R = R < S R Site 2 Site 2 computes R S Semijoin is better if INGRES is based on three ideas: Decompose query q into q 1 q 2 q n The output or q i is send to the input of q i+1. Each q i is a mono-variable query Detachment and tuple substitution is used to achieve the decomposition There s a processor that can processes each one variable query efficiently size(π A (S)) + size(r < S) < size(r) Spring, 2006 Arturas Mazeika Page 23 Spring, 2006 Arturas Mazeika Page 24
7 INGRES Centralized Algorithm (Example, Detachment 1/2) Consider the query of names of employees working on CAD/CAM project. q 1 : SELECT EMP.ENAME FROM EMP, ASG, PROJ WHERE EMP.ENO=ASG.ENO AND ASG.PNO=PROJ.PNO AND PROJ.PNAME="CAD/CAM" Change q 1 into q 11 q : q 11 : q : SELECT PROJ.PNO INTO JVAR FROM PROJ WHERE PROJ.PNAME="CAD/CAM" SELECT EMP.ENAME FROM EMP,ASG,JVAR WHERE EMP.ENO=ASG.ENO AND ASG.PNO=JVAR.PNO Spring, 2006 Arturas Mazeika Page 25 INGRES Centralized Algorithm (Example, Tuple Substitution) q : INGRES Centralized Algorithm (Example, Detachment 2/2) Change q into q 12 q 13 : q 12 : q 13 : SELECT EMP.ENAME FROM EMP,ASG,JVAR WHERE EMP.ENO=ASG.ENO AND ASG.PNO=JVAR.PNO SELECT ASG.ENO INTO GVAR FROM ASG,JVAR WHERE ASG.PNO=JVAR.PNO SELECT EMP.ENAME FROM EMP,GVAR WHERE EMP.ENO=GVAR.ENO q 11 is a mono-variable query, q 12 and q 13 are not mono-variable queries (yet) Spring, 2006 Arturas Mazeika Page 26 Distributed INGRES Algorithm Assume GV AR consists only the tuples {E1, E2} then q 13 is rewritten with tuple substitution in the following way q 131 SELECT EMP.ENAME FROM EMP WHERE EMP.ENO="E1" q 132 : SELECT EMP.ENAME FROM EMP WHERE EMP.ENO="E2" The distributed INGRES algorithm is very similar to the centralized INGRES algorithm. In addition to the centralized INGRES the distributed one should break up each query q i into sub-queries that operation on fragments. Optimization with respect to communication cost or response time is possible Spring, 2006 Arturas Mazeika Page 27 Spring, 2006 Arturas Mazeika Page 28
8 System R Algorithm System R Algorithm (Example 1/2) Consider the query of the names of employees working on the CAD/CAM project P ROJ P NO ASG ENO EMP The algorithm is based on two ideas: Execute simple (mono-variable) queries based on the best plan (using index, scan, etc) Execute joins Determine the possible ordering of joins Determine the cost of each ordering Choose the join ordering with minimal cost Spring, 2006 Arturas Mazeika Page 29 System R Algorithm (Example 2/2) Spring, 2006 Arturas Mazeika Page 30 Distributed System R Algorithm Only the whole relations can be distributed One central site decides the ordering of joins (intra-site optimization). The local sites decides the local optimizations the local joins (inter-site optimization) Three main strategies for join R S: Join at R site Join at S site Join at the result site Data transfer possibilities: Ship-whole Fetch-as-needed Best total join order is either ((ASG EMP) PROJ) or ((PROJ ASG) EMP) Spring, 2006 Arturas Mazeika Page 31 Spring, 2006 Arturas Mazeika Page 32
9 Distributed System R Algorithm (Data Transfer) Distributed System R Algorithm (Strategy 1) Ship whole Larger data transfer Smaller number of messages Better if relations are small Fetch as needed Number of messages = O(cardinality of external relation) Data transfer per message is minimal Better if relations are large and the selectivity is good Move outer relation tuples to the site of the inner relation (a) Retrieve outer tuples (b) Send them to the inner relation site (c) Join them as they arrive Total Cost = cost(retrieving qualified outer tuples) + no. of outer tuples fetched cost(retrieving qualified inner tuples) + msg. cost (no. outer tuples fetched avg. outer tuple size)/msg. size Spring, 2006 Arturas Mazeika Page 33 Distributed System R Algorithm (Strategy 2) Spring, 2006 Arturas Mazeika Page 34 Distributed System R Algorithm (Strategy 3) Move inner relation to the site of outer relation. We cannot join as they arrive; they need to be stored Total Cost = cost(retrieving qualified outer tuples) + no. of outer tuples fetched cost(retrieving matching inner tuples from temporary storage) + cost(retrieving qualified inner tuples) + cost(storing all qualified inner tuples in temporary storage) + msg. cost (no. of inner tuples fetched avg. inner tuple size)/msg. size Move both inner and outer relations to another site Total cost = cost(retrieving qualified outer tuples) + cost(retrieving qualified inner tuples) + cost(storing inner tuples in storage) + msg. cost (no. of outer tuples fetched avg. outer tuple size)/msg. size + msg. cost (no. of inner tuples fetched avg. inner tuple size)/msg. size + no. of outer tuples fetched cost(retrieving inner tuples from temporary storage) Spring, 2006 Arturas Mazeika Page 35 Spring, 2006 Arturas Mazeika Page 36
10 Distributed System R Algorithm (Strategy 4) Hill Climbing Algorithm Fetch inner tuples as needed (a) Retrieve qualified tuples at outer relation site (b) Send request containing join column value(s) for outer tuples to inner relation site (c) Retrieve matching inner tuples at inner relation site (d) Send the matching inner tuples to outer relation site (e) Join as they arrive Total Cost = cost(retrieving qualified outer tuples) + msg. cost (no. of outer tuples fetched) + no. of outer tuples fetched (no. of inner tuples fetched avg. inner tuple size msg. cost/msg. size) + no. of outer tuples fetched cost(retrieving matching inner tuples for one outer value) 1. : Select initial feasible solution ES0 1.1 Determine the candidate result sites - sites where a relation referenced in the query exist 1.2 Compute the cost of transferring all the other referenced relations to each candidate site 1.3 ES0 = candidate site with minimum cost 2. Determine candidate splits of ES0 into ES1, ES2 2.1 ES1 consists of sending one of the relations to the other relation s site 2.2 ES2 consists of sending the join of the relations to the final result site 3. Replace ES0 with the split schedule which gives cost(es1) + cost(local join) + cost(es2) < cost(es0) 4. Recursively apply steps 2-3 on ES1 and ES2 until no such plans can be found 5. Check for redundant transmissions in the final plan and eliminate them Spring, 2006 Arturas Mazeika Page 37 Hill Climbing Algorithm (Example, Assumption) What are the salaries of engineers who work on the CAD/CAM project? Π SAL (P AY T IT LE EMP ENO (ASG P NO (σ P NAME= CAD/CAM (P ROJ)))) Spring, 2006 Arturas Mazeika Page 38 Hill Climbing Algorithm (Example, Step 1:Initial feasible solution) Alternative 1: Resulting site is Site 1 Costs Relation Size Site EMP 8 1 PAY 4 2 PROJ 4 3 ASG 10 4 Table 1: Statistics Total cost = cost(paysite 1) + cost(asgsite 1) + cost(projsite 1) = = 15 Alternative 2: Resulting site is Site 2 Alternative 3: Resulting site is Site 3 Total cost = = 19 Total cost = = 22 Assumptions: Size of relations is defined as their cardinality Minimize total cost Transmission cost between two sites is 1 Ignore local processing cost Alternative 4: Resulting site is Site 4 Total cost = = 13 Therefore ES0 = EMP Site 4; S Site 4; PROJ Site 4 Spring, 2006 Arturas Mazeika Page 39 Spring, 2006 Arturas Mazeika Page 40
11 Hill Climbing Algorithm (Example, Step 2: Candidate Splits 1/2) Hill Climbing Algorithm (Example, Step 2: Candidate Splits 2/2) Alternative 1: ES1, ES2, ES3 where ES1: EMP Site 2 ES2: (EMP PAY) Site 4 ES3: PROJ Site 4 Alternative 2: ES1, ES2, ES3 where ES1: PAY Site 1 ES2: (PAY EMP) Site 4 ES3: PROJ Site 4 Costs Alternative 1: cost(empsite 2) + cost((emp PAY) Site 4) + cost(proj Site 4) = = 17 Alternative 2: cost(paysite 1) + cost((pay EMP) Site 4) + cost(proj Site 4) = = 13 Alternative 2 is the best Spring, 2006 Arturas Mazeika Page 41 Hill Climbing Algorithm (Conclusion) Spring, 2006 Arturas Mazeika Page 42 SDD-1 Problems : Greedy algorithm determines an initial feasible solution and iteratively tries to improve it If there are local minimums, it may not find the global minima If the optimal schedule has a high initial cost, it won t find it since it won t choose it as the initial feasible solution Example : A better schedule is PROJ Site 4 ASG = (PROJ ASG) Site 1 (ASG EMP) Site 2 Total cost= = 5 Improves Hill Climbing Algorithm with the following: Semijoins More elaborate statistics Initial plan is selected better Post-optimization step is introduced Spring, 2006 Arturas Mazeika Page 43 Spring, 2006 Arturas Mazeika Page 44
12 Conclusion Distributed query optimization is more complex that centralized query processing, since (i) bushy query trees are not necessarily a bad choice, (ii) one needs to decide what, where, and how to ship the relations between the sites Query optimization searches the optimal query plan (tree) For N relations, there are O(N!) equivalent join trees. To cope with the complexity heuristics and/or restricted types of trees are considered There are two main strategies in query optimization: randomized and deterministic (Few) semi-joins can used to implement a join. The semi-joins requires more operations to perform, however reduces the data transfer rate INGRES, System R, and Hill Climbing algorithms are used to optimize quries Spring, 2006 Arturas Mazeika Page 45
Introduction Background Distributed DBMS Architecture Distributed Database Design Semantic Data Control Distributed Query Processing
Outline Introduction Background Distributed DBMS Architecture Distributed Database Design Semantic Data Control Distributed Query Processing Query Processing Methodology Distributed Query Optimization
More informationIntroduction Background Distributed DBMS Architecture Distributed Database Design Semantic Data Control Distributed Query Processing
Outline Introduction Background Distributed DBMS Architecture Distributed Database Design Semantic Data Control Distributed Query Processing Query Processing Methodology Distributed Query Optimization
More informationCS54200: Distributed. Introduction
CS54200: Distributed Database Systems Query Processing 9 March 2009 Prof. Chris Clifton Query Processing Introduction Converting user commands from the query language (SQL) to low level data manipulation
More informationChapter 4 Distributed Query Processing
Chapter 4 Distributed Query Processing Table of Contents Overview of Query Processing Query Decomposition and Data Localization Optimization of Distributed Queries Chapter4-1 1 1. Overview of Query Processing
More informationQuery Decomposition and Data Localization
Query Decomposition and Data Localization Query Decomposition and Data Localization Query decomposition and data localization consists of two steps: Mapping of calculus query (SQL) to algebra operations
More informationMobile and Heterogeneous databases Distributed Database System Query Processing. A.R. Hurson Computer Science Missouri Science & Technology
Mobile and Heterogeneous databases Distributed Database System Query Processing A.R. Hurson Computer Science Missouri Science & Technology 1 Note, this unit will be covered in four lectures. In case you
More informationQuery Processing. high level user query. low level data manipulation. query processor. commands
Query Processing high level user query query processor low level data manipulation commands 1 Selecting Alternatives SELECT ENAME FROM EMP,ASG WHERE EMP.ENO = ASG.ENO AND DUR > 37 Strategy A ΠENAME(σDUR>37
More informationQUERY 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 informationQUERY 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 informationQuery Processing SL03
Distributed Database Systems Fall 2016 Query Processing Overview Query Processing SL03 Distributed Query Processing Steps Query Decomposition Data Localization Query Processing Overview/1 Query processing:
More informationDistributed Query Optimization: Use of mobile Agents Kodanda Kumar Melpadi
Distributed Query Optimization: Use of mobile Agents Kodanda Kumar Melpadi M.Tech (IT) GGS Indraprastha University Delhi mk_kumar_76@yahoo.com Abstract DDBS adds to the conventional centralized DBS some
More informationDistributed Databases Systems
Distributed Databases Systems Lecture No. 05 Query Processing Naeem Ahmed Email: naeemmahoto@gmail.com Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Outline
More informationQuery 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 informationIntegration of Transactional Systems
Integration of Transactional Systems Distributed Query Processing Robert Wrembel Poznań University of Technology Institute of Computing Science Robert.Wrembel@cs.put.poznan.pl www.cs.put.poznan.pl/rwrembel
More informationQuery optimization. Query Optimization. Query Optimization. Cost estimation. Another reason why plain IOs not enough: Parallelism
Query optimization Query Optimization It is safer to accept any chance that offers itself, and extemporize a procedure to fit it, than to get a good plan matured, and wait for a chance of using it. Thomas
More informationHash-Based Indexing 165
Hash-Based Indexing 165 h 1 h 0 h 1 h 0 Next = 0 000 00 64 32 8 16 000 00 64 32 8 16 A 001 01 9 25 41 73 001 01 9 25 41 73 B 010 10 10 18 34 66 010 10 10 18 34 66 C Next = 3 011 11 11 19 D 011 11 11 19
More informationDistributed caching for multiple databases
Distributed caching for multiple databases K. V. Santhilata, Post Graduate Research Student, Department of Informatics, School of Natural and Mathematical Sciences, King's College London, London, U.K 1
More informationDatabase 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 informationMobile and Heterogeneous databases
Mobile and Heterogeneous databases Heterogeneous Distributed Databases Query Processing A.R. Hurson Computer Science Missouri Science & Technology 1 Note, this unit will be covered in two lectures. In
More informationChapter 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 informationQuery 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 informationQuery 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 informationQuery Processing and Optimization *
OpenStax-CNX module: m28213 1 Query Processing and Optimization * Nguyen Kim Anh This work is produced by OpenStax-CNX and licensed under the Creative Commons Attribution License 3.0 Query processing is
More informationIntroduction 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 informationEvaluation of Relational Operations: Other Techniques. Chapter 14 Sayyed Nezhadi
Evaluation of Relational Operations: Other Techniques Chapter 14 Sayyed Nezhadi Schema for Examples Sailors (sid: integer, sname: string, rating: integer, age: real) Reserves (sid: integer, bid: integer,
More informationOutline. Distributed DBMS Page 5. 1
Outline Introduction Background Distributed DBMS Architecture Distributed Database Design Fragmentation Data Location Semantic Data Control Distributed Query Processing Distributed Transaction Management
More informationCS 347 Parallel and Distributed Data Processing
C 37 Parallel and Distributed Data Processing pring 2016 Notes : Query Optimization Query Optimization Cost estimation trategies for exploring plans Q min C 37 Notes 2 Based on estimating result sizes
More informationTotalCost = 3 (1, , 000) = 6, 000
156 Chapter 12 HASH JOIN: Now both relations are the same size, so we can treat either one as the smaller relation. With 15 buffer pages the first scan of S splits it into 14 buckets, each containing about
More informationOutline. Distributed DBMS 1998 M. Tamer Özsu & Patrick Valduriez
Outline Introduction Background Distributed DBMS Architecture Distributed Database Design Semantic Data Control View Management Data Security Semantic Integrity Control Distributed Query Processing Distributed
More informationCS 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 informationChapter 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 informationIntroduction 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 informationAdvanced 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 informationCSE 444: Database Internals. Lecture 22 Distributed Query Processing and Optimization
CSE 444: Database Internals Lecture 22 Distributed Query Processing and Optimization CSE 444 - Spring 2014 1 Readings Main textbook: Sections 20.3 and 20.4 Other textbook: Database management systems.
More informationParallel Query Optimisation
Parallel Query Optimisation Contents Objectives of parallel query optimisation Parallel query optimisation Two-Phase optimisation One-Phase optimisation Inter-operator parallelism oriented optimisation
More informationCMSC424: 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 informationOn Building Integrated and Distributed Database Systems
On Building Integrated and Distributed Database Systems Distributed Query Processing and Optimization Robert Wrembel Poznań University of Technology Institute of Computing Science Poznań,, Poland Robert.Wrembel@cs.put.poznan.pl
More informationChapter 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 informationChapter 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 informationCSC 261/461 Database Systems Lecture 19
CSC 261/461 Database Systems Lecture 19 Fall 2017 Announcements CIRC: CIRC is down!!! MongoDB and Spark (mini) projects are at stake. L Project 1 Milestone 4 is out Due date: Last date of class We will
More informationRelational Model History. COSC 304 Introduction to Database Systems. Relational Model and Algebra. Relational Model Definitions.
COSC 304 Introduction to Database Systems Relational Model and Algebra Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca Relational Model History The relational model was
More informationQuery Optimization. Shuigeng Zhou. December 9, 2009 School of Computer Science Fudan University
Query Optimization Shuigeng Zhou December 9, 2009 School of Computer Science Fudan University Outline Introduction Catalog Information for Cost Estimation Estimation of Statistics Transformation of Relational
More informationQuery Optimization Overview
Query Optimization Overview parsing, syntax checking semantic checking check existence of referenced relations and attributes disambiguation of overloaded operators check user authorization query rewrites
More informationRelational Model History. COSC 416 NoSQL Databases. Relational Model (Review) Relation Example. Relational Model Definitions. Relational Integrity
COSC 416 NoSQL Databases Relational Model (Review) Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca Relational Model History The relational model was proposed by E. F. Codd
More information! 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 informationChapter 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 informationQuery 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 informationChapter 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 informationChapter 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 informationCopyright 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 informationAlgorithms 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 informationParallel DBMS. Parallel Database Systems. PDBS vs Distributed DBS. Types of Parallelism. Goals and Metrics Speedup. Types of Parallelism
Parallel DBMS Parallel Database Systems CS5225 Parallel DB 1 Uniprocessor technology has reached its limit Difficult to build machines powerful enough to meet the CPU and I/O demands of DBMS serving large
More informationDatabase Systems External Sorting and Query Optimization. A.R. Hurson 323 CS Building
External Sorting and Query Optimization A.R. Hurson 323 CS Building External sorting When data to be sorted cannot fit into available main memory, external sorting algorithm must be applied. Naturally,
More informationFaloutsos 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 informationDISTRIBUTED QUERY OPTIMIZATION USING HILL CLIMBING ALGORITHM FOR COMPLEX CHURCH DATABASES
DISTRIBUTED QUERY OPTIMIZATION USING HILL CLIMBING ALGORITHM FOR COMPLEX CHURCH DATABASES Esiefarienrhe Michael Bukohwo 1, Philemon Uten Emmoh 2 and Choji Davou Nyab 3 1,2 Department of Mathematics/Statistics/ComputerScience,University
More informationRelational Model: History
Relational Model: History Objectives of Relational Model: 1. Promote high degree of data independence 2. Eliminate redundancy, consistency, etc. problems 3. Enable proliferation of non-procedural DML s
More informationImplementation of Relational Operations. Introduction. CS 186, Fall 2002, Lecture 19 R&G - Chapter 12
Implementation of Relational Operations CS 186, Fall 2002, Lecture 19 R&G - Chapter 12 First comes thought; then organization of that thought, into ideas and plans; then transformation of those plans into
More informationQuery 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 informationOutline. q Database integration & querying. q Peer-to-Peer data management q Stream data management q MapReduce-based distributed data management
Outline n Introduction & architectural issues n Data distribution n Distributed query processing n Distributed query optimization n Distributed transactions & concurrency control n Distributed reliability
More informationQUERY OPTIMIZATION [CH 15]
Spring 2017 QUERY OPTIMIZATION [CH 15] 4/12/17 CS 564: Database Management Systems; (c) Jignesh M. Patel, 2013 1 Example SELECT distinct ename FROM Emp E, Dept D WHERE E.did = D.did and D.dname = Toy EMP
More informationTHE EFFECT OF JOIN SELECTIVITIES ON OPTIMAL NESTING ORDER
THE EFFECT OF JOIN SELECTIVITIES ON OPTIMAL NESTING ORDER Akhil Kumar and Michael Stonebraker EECS Department University of California Berkeley, Ca., 94720 Abstract A heuristic query optimizer must choose
More informationCOSC 304 Introduction to Database Systems SQL. Dr. Ramon Lawrence University of British Columbia Okanagan
COSC 304 Introduction to Database Systems SQL Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca SQL Queries Querying with SQL is performed using a SELECT statement. The general
More informationImplementing Relational Operators: Selection, Projection, Join. Database Management Systems, R. Ramakrishnan and J. Gehrke 1
Implementing Relational Operators: Selection, Projection, Join Database Management Systems, R. Ramakrishnan and J. Gehrke 1 Readings [RG] Sec. 14.1-14.4 Database Management Systems, R. Ramakrishnan and
More information192 Chapter 14. TotalCost=3 (1, , 000) = 6, 000
192 Chapter 14 5. SORT-MERGE: With 52 buffer pages we have B> M so we can use the mergeon-the-fly refinement which costs 3 (M + N). TotalCost=3 (1, 000 + 1, 000) = 6, 000 HASH JOIN: Now both relations
More informationDatabase 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 informationPublished by: PIONEER RESEARCH & DEVELOPMENT GROUP (www.prdg.org) 1
Optimization of Join Queries on Distributed Relations Using Semi-Joins Suresh Sapa 1, K. P. Supreethi 2 1, 2 JNTUCEH, Hyderabad, India Abstract The processing and optimizing a join query in distributed
More informationChapter 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 informationCS122 Lecture 10 Winter Term,
CS122 Lecture 10 Winter Term, 2014-2015 2 Last Time: Plan Cos0ng Last time, introduced ways of approximating plan costs Number of rows each plan node produces Amount of disk IO the plan must perform Database
More informationSQL Queries. COSC 304 Introduction to Database Systems SQL. Example Relations. SQL and Relational Algebra. Example Relation Instances
COSC 304 Introduction to Database Systems SQL Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca SQL Queries Querying with SQL is performed using a SELECT statement. The general
More informationQuery 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 informationBackground. Chapter Overview of Relational DBMS Relational Database Concepts
Chapter 2 Background As indicated in the previous chapter, there are two technological bases for distributed database technology: database management and computer networks. In this chapter, we provide
More informationDatabase 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 informationSomething 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 information2.2.2.Relational Database concept
Foreign key:- is a field (or collection of fields) in one table that uniquely identifies a row of another table. In simpler words, the foreign key is defined in a second table, but it refers to the primary
More informationMahathma Gandhi University
Mahathma Gandhi University BSc Computer science III Semester BCS 303 OBJECTIVE TYPE QUESTIONS Choose the correct or best alternative in the following: Q.1 In the relational modes, cardinality is termed
More informationCAS CS 460/660 Introduction to Database Systems. Query Evaluation II 1.1
CAS CS 460/660 Introduction to Database Systems Query Evaluation II 1.1 Cost-based Query Sub-System Queries Select * From Blah B Where B.blah = blah Query Parser Query Optimizer Plan Generator Plan Cost
More informationBasant Group of Institution
Basant Group of Institution Visual Basic 6.0 Objective Question Q.1 In the relational modes, cardinality is termed as: (A) Number of tuples. (B) Number of attributes. (C) Number of tables. (D) Number of
More informationCS54200: Distributed Database Systems
CS54200: Distributed Database Systems Distributed Database Design 23 February, 2009 Prof. Chris Clifton Design Problem In the general setting: Making decisions about the placement of data and programs
More informationSDD-1 Algorithm Implementation
National Institute of Technology Karnataka, Surathkal Project Report on SDD-1 Algorithm Implementation Under the Guidance of: Mr. Dr. Anantha Narayana (Professor) Submitted by: Mr. Vasanth Raja Chittampally
More informationσ (R.B = 1 v R.C > 3) (S.D = 2) Conjunctive normal form Topics for the Day Distributed Databases Query Processing Steps Decomposition
Topics for the Day Distributed Databases Query processing in distributed databases Localization Distributed query operators Cost-based optimization C37 Lecture 1 May 30, 2001 1 2 Query Processing teps
More informationA subquery is a nested query inserted inside a large query Generally occurs with select, from, where Also known as inner query or inner select,
Sub queries A subquery is a nested query inserted inside a large query Generally occurs with select, from, where Also known as inner query or inner select, Result of the inner query is passed to the main
More informationOverview of Query Processing and Optimization
Overview of Query Processing and Optimization Source: Database System Concepts Korth and Silberschatz Lisa Ball, 2010 (spelling error corrections Dec 07, 2011) Purpose of DBMS Optimization Each relational
More informationAnnouncement. 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 informationInformationslogistik 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 informationCs712 Important Questions & Past Papers
Cs712 Distributed Database Q1. Differentiate Horizontal and vertical partitions? Vertical Fragmentation: Different subsets of attributes are stored at different places, like, Table EMP (eid, ename, edept,
More informationCMPUT 391 Database Management Systems. An Overview of Query Processing. Textbook: Chapter 11 (first edition: Chapter 14)
CMPUT 391 Database Management Systems Winter Semester 2006, Section B1, Dr. Jörg Sander An Overview of Query Processing Textbook: Chapter 11 (first edition: Chapter 14) Based on slides by Lewis, Bernstein
More informationQuery Optimization Overview
Query Optimization Overview parsing, syntax checking semantic checking check existence of referenced relations and attributes disambiguation of overloaded operators check user authorization query rewrites
More informationOverview of Query Evaluation
Overview of Query Evaluation Chapter 12 Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Overview of Query Evaluation Plan: Tree of R.A. operators, with choice of algorithm for each operator.
More informationChapter 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 informationChapter 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 informationChapter 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 informationContents 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 informationTechno India Batanagar Computer Science and Engineering. Model Questions. Subject Name: Database Management System Subject Code: CS 601
Techno India Batanagar Computer Science and Engineering Model Questions Subject Name: Database Management System Subject Code: CS 601 Multiple Choice Type Questions 1. Data structure or the data stored
More informationQUERY OPTIMIZATION. CS 564- Spring ACKs: Jeff Naughton, Jignesh Patel, AnHai Doan
QUERY OPTIMIZATION CS 564- Spring 2018 ACKs: Jeff Naughton, Jignesh Patel, AnHai Doan WHAT IS THIS LECTURE ABOUT? What is a query optimizer? Generating query plans Cost estimation of query plans 2 ARCHITECTURE
More informationCS122 Lecture 15 Winter Term,
CS122 Lecture 15 Winter Term, 2014-2015 2 Index Op)miza)ons So far, only discussed implementing relational algebra operations to directly access heap Biles Indexes present an alternate access path for
More informationFundamentals of Database Systems
Fundamentals of Database Systems Assignment: 4 September 21, 2015 Instructions 1. This question paper contains 10 questions in 5 pages. Q1: Calculate branching factor in case for B- tree index structure,
More informationChapter 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 informationWhat is Data? Volatile vs. persistent data Our concern is primarily with persistent data
What is? ANSI definition: ❶ A representation of facts, concepts, or instructions in a formalized manner suitable for communication, interpretation, or processing by humans or by automatic means. ❷ Any
More informationWhat is Data? ANSI definition: Volatile vs. persistent data. Data. Our concern is primarily with persistent data
What is Data? ANSI definition: Data ❶ A representation of facts, concepts, or instructions in a formalized manner suitable for communication, interpretation, or processing by humans or by automatic means.
More informationEvaluation of Relational Operations
Evaluation of Relational Operations Yanlei Diao UMass Amherst March 13 and 15, 2006 Slides Courtesy of R. Ramakrishnan and J. Gehrke 1 Relational Operations We will consider how to implement: Selection
More information