《数据库系统概念 Database System Concepts》原书教学资源(第六版,PPT课件讲稿,英文版)Chapter 13 Query Optimization

Chapter 13:Query Optimization Introduction Transformation of Relational Expressions Catalog Information for Cost Estimation Statistical Information for Cost Estimation Cost-based optimization Dynamic Programming for Choosing Evaluation Plans Materialized views Database System Concepts-6th Edition 1.2 ©Silberschat乜,Korth and Sudarshan
Database System Concepts - 6 1.2 ©Silberschatz, Korth and Sudarshan th Edition Chapter 13: Query Optimization Introduction Transformation of Relational Expressions Catalog Information for Cost Estimation Statistical Information for Cost Estimation Cost-based optimization Dynamic Programming for Choosing Evaluation Plans Materialized views

Introduction Alternative ways of evaluating a given query Equivalent expressions Different algorithms for each operation Π ame,title name,title dept_name Music instructor Odept_name=Music teaches course instructor teaches course Database System Concepts-6th Edition 1.3 ©Silberschat乜,Korth and Sudarshan
Database System Concepts - 6 1.3 ©Silberschatz, Korth and Sudarshan th Edition Introduction Alternative ways of evaluating a given query Equivalent expressions Different algorithms for each operation

Introduction (Cont.) An evaluation plan defines exactly what algorithm is used for each operation,and how the execution of the operations is coordinated. I(t to remove duplicates) (hash join) (merge join) course pipeline pipeline dept_name-Music 0 year=2009 (use index 1) (use linear scan)) instructor teaches Find out how to view query execution plans on your favorite database Database System Concepts-6th Edition 1.4 ©Silberschat乜,Korth and Sudarshan
Database System Concepts - 6 1.4 ©Silberschatz, Korth and Sudarshan th Edition Introduction (Cont.) An evaluation plan defines exactly what algorithm is used for each operation, and how the execution of the operations is coordinated. Find out how to view query execution plans on your favorite database

Introduction(Cont.) Cost difference between evaluation plans for a query can be enormous E.g.seconds vs.days in some cases Steps in cost-based query optimization 1.Generate logically equivalent expressions using equivalence rules 2.Annotate resultant expressions to get alternative query plans 3.Choose the cheapest plan based on estimated cost Estimation of plan cost based on: Statistical information about relations.Examples: number of tuples,number of distinct values for an attribute Statistics estimation for intermediate results to compute cost of complex expressions Cost formulae for algorithms,computed using statistics Database System Concepts-6th Edition 1.5 ©Silberschat乜,Korth and Sudarshan
Database System Concepts - 6 1.5 ©Silberschatz, Korth and Sudarshan th Edition Introduction (Cont.) Cost difference between evaluation plans for a query can be enormous E.g. seconds vs. days in some cases Steps in cost-based query optimization 1. Generate logically equivalent expressions using equivalence rules 2. Annotate resultant expressions to get alternative query plans 3. Choose the cheapest plan based on estimated cost Estimation of plan cost based on: Statistical information about relations. Examples: number of tuples, number of distinct values for an attribute Statistics estimation for intermediate results to compute cost of complex expressions Cost formulae for algorithms, computed using statistics

☒无法显示该图片。 Generating Equivalent Expressions Database System Concepts,6th Ed. @Silberschatz,Korth and Sudarshan See www.db-book.com for conditions on re-use
Database System Concepts, 6th Ed. ©Silberschatz, Korth and Sudarshan See www.db-book.com for conditions on re-use Generating Equivalent Expressions

Transformation of Relational Expressions Two relational algebra expressions are said to be equivalent if the two expressions generate the same set of tuples on every lega/database instance Note:order of tuples is irrelevant we don't care if they generate different results on databases that violate integrity constraints In SQL,inputs and outputs are multisets of tuples Two expressions in the multiset version of the relational algebra are said to be equivalent if the two expressions generate the same multiset of tuples on every legal database instance. An equivalence rule says that expressions of two forms are equivalent Can replace expression of first form by second,or vice versa Database System Concepts-6th Edition 1.7 ©Silberschat乜,Korth and Sudarshan
Database System Concepts - 6 1.7 ©Silberschatz, Korth and Sudarshan th Edition Transformation of Relational Expressions Two relational algebra expressions are said to be equivalent if the two expressions generate the same set of tuples on every legal database instance Note: order of tuples is irrelevant we don’t care if they generate different results on databases that violate integrity constraints In SQL, inputs and outputs are multisets of tuples Two expressions in the multiset version of the relational algebra are said to be equivalent if the two expressions generate the same multiset of tuples on every legal database instance. An equivalence rule says that expressions of two forms are equivalent Can replace expression of first form by second, or vice versa

Equivalence Rules 1.Conjunctive selection operations can be deconstructed into a sequence of individual selections. o le,(E)=Oe (o,(E)) 2.Selection operations are commutative. o6(o4,(E)=04,(oa(E) 3.( Only the last in a sequence of projection operations is needed,the others can be omitted. Πz(Π,(.(n(E).…)=Π(E) 4.Selections can be combined with Cartesian products and theta joins. a.( a(E1XE2)=E1凶9E2 b.( 01(E1凶92E2)=E1M1A2E2 Database System Concepts-6th Edition 1.8 @Silberschatz,Korth and Sudarshan
Database System Concepts - 6 1.8 ©Silberschatz, Korth and Sudarshan th Edition Equivalence Rules 1. Conjunctive selection operations can be deconstructed into a sequence of individual selections. 2. Selection operations are commutative. 3. Only the last in a sequence of projection operations is needed, the others can be omitted. 4. Selections can be combined with Cartesian products and theta joins. a. (E1 X E2 ) = E1 E2 b. 1 (E1 2 E2 ) = E1 1 2 E2 ( ( )) ( ( )) 1 2 2 1 sq sq E =sq sq E ( ) ( ( )) 1 2 1 2 sq Ùq E =sq sq E ( ( ( ( )) )) ( ) 1 2 1 L L Ln E = L E

Equivalence Rules (Cont.) 5.Theta-join operations (and natural joins)are commutative. E1凶gE2=E2凶9E1 6.(a)Natural join operations are associative: (E1凶E2)凶E3=E1凶(E2冈E3) (b)Theta joins are associative in the following manner: (E1凶01E2)凶923E3=E1凶01A03(E2凶92E3) where 02 involves attributes from only E2 and E3. Database System Concepts-6th Edition 1.9 @Silberschatz,Korth and Sudarshan
Database System Concepts - 6 1.9 ©Silberschatz, Korth and Sudarshan th Edition Equivalence Rules (Cont.) 5. Theta-join operations (and natural joins) are commutative. E1 E2 = E2 E1 6. (a) Natural join operations are associative: (E1 E2 ) E3 = E1 (E2 E3 ) (b) Theta joins are associative in the following manner: (E1 1 E2 ) 2 3 E3 = E1 1 3 (E2 2 E3 ) where 2 involves attributes from only E2 and E3

Pictorial Depiction of Equivalence Rules Rule 5 0 E1 E2 E2 E1 凶 Rule 6a 凶 E3 E1 E1 E2 E2 E3 Rule 7a 凶 If 0 only has attributes from El 68 E2 E1 E2 E1 Database System Concepts-6th Edition 1.10 @Silberschatz,Korth and Sudarshan
Database System Concepts - 6 1.10 ©Silberschatz, Korth and Sudarshan th Edition Pictorial Depiction of Equivalence Rules

Equivalence Rules (Cont.) 7.The selection operation distributes over the theta join operation under the following two conditions: (a)When all the attributes in 00 involve only the attributes of one of the expressions(E)being joined. oo(E1☒6E2)=(oo(E1)凶gE2 (b)When01 involves only the attributes of E1 and 02 involves only the attributes of E2. o91N2(E1凶9E2)=(o1(E1)凶(o2(E2) Database System Concepts-6th Edition 1.11 @Silberschatz,Korth and Sudarshan
Database System Concepts - 6 1.11 ©Silberschatz, Korth and Sudarshan th Edition Equivalence Rules (Cont.) 7. The selection operation distributes over the theta join operation under the following two conditions: (a) When all the attributes in 0 involve only the attributes of one of the expressions (E1 ) being joined. 0 (E1 E2 ) = (0 (E1 )) E2 (b) When 1 involves only the attributes of E1 and 2 involves only the attributes of E2 . 1 (E1 E2 ) = (1 (E1 )) ( (E2 ))
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 《数据库系统概念 Database System Concepts》原书教学资源(第六版,PPT课件讲稿,英文版)Chapter 12 Query Processing.ppt
- 《数据库系统概念 Database System Concepts》原书教学资源(第六版,PPT课件讲稿,英文版)Chapter 11 Indexing and Hashing.ppt
- 《数据库系统概念 Database System Concepts》原书教学资源(第六版,PPT课件讲稿,英文版)Chapter 10 Storage and File Structure.ppt
- 《数据库系统概念 Database System Concepts》原书教学资源(第六版,PPT课件讲稿,英文版)Chapter 1 Introduction(Avi Silberschatz Henry F. Korth S. Sudarshan).ppt
- 电子科技大学:《大数据时代商业模式创新 Business model innovation》研究生课程教学资源(课件讲稿,杜义飞).pdf
- 电子科技大学:《大数据时代商业模式创新 Business model innovation》研究生课程教学资源(讲座)换一个视角看清商业本质.pdf
- 电子科技大学:《大数据时代商业模式创新 Business Model Innovation in the Times of Big Data》研究生课程教学资源(教学大纲,杜义飞).pdf
- 《物联网技术导论 Introduction of Internet of Things》课程教学资源(参考文献)群智感知计算(清华大学:在后台操纵的同时,用户对于污染、扭曲文字的识 刘云浩).pdf
- 南京大学:《物联网技术导论 Introduction of Internet of Things》课程教学资源(参考文献)基于位置服的务(架构与研究进展).pdf
- 南京大学:《物联网技术导论 Introduction of Internet of Things》课程教学资源(参考文献)Wi-Fi雷达 - 从RSSI到CSI.pdf
- 南京大学:《物联网技术导论 Introduction of Internet of Things》课程教学资源(参考文献)Survey of Wireless Indoor Positioning Techniques and Systems.pdf
- 南京大学:《物联网技术导论 Introduction of Internet of Things》课程教学资源(参考文献)Location, Localization, and Localizability.pdf
- RFID标签数目估算机制研究(参考文献)ZOE - Fast Cardinality Estimation for Large-Scale RFID Systems.pdf
- RFID标签数目估算机制研究(参考文献)Every Bit Counts - Fast and Scalable RFID Estimation.pdf
- RFID标签数目估算机制研究(参考文献)Energy Efficient Algorithms for the RFID Estimation Problem.pdf
- RFID标签数目估算机制研究(参考文献)Counting RFID Tags Efficiently and Anonymously.pdf
- RFID标签数目估算机制研究(参考文献)An Efficient Protocol for RFID Multigroup Threshold-based Classification.pdf
- RFID标签识别机制-冲突以及防冲突算法研究(参考文献)Using Analog Network Coding to Improve the RFID Reading Throughput.pdf
- RFID标签识别机制-冲突以及防冲突算法研究(参考文献)Season Shelving Interference and Joint Identification in Large-scale RFID Systems.pdf
- RFID标签识别机制-冲突以及防冲突算法研究(参考文献)Probabilistic Optimal Tree Hopping for RFID Identification.pdf
- 《数据库系统概念 Database System Concepts》原书教学资源(第六版,PPT课件讲稿,英文版)Chapter 14 Transactions.ppt
- 《数据库系统概念 Database System Concepts》原书教学资源(第六版,PPT课件讲稿,英文版)Chapter 15 Concurrency Control.ppt
- 《数据库系统概念 Database System Concepts》原书教学资源(第六版,PPT课件讲稿,英文版)Chapter 16 Recovery System.ppt
- 《数据库系统概念 Database System Concepts》原书教学资源(第六版,PPT课件讲稿,英文版)Chapter 17 Database System Architectures.ppt
- 《数据库系统概念 Database System Concepts》原书教学资源(第六版,PPT课件讲稿,英文版)Chapter 18 Parallel Databases.ppt
- 《数据库系统概念 Database System Concepts》原书教学资源(第六版,PPT课件讲稿,英文版)Chapter 19 Distributed Databases.ppt
- 《数据库系统概念 Database System Concepts》原书教学资源(第六版,PPT课件讲稿,英文版)Chapter 2 Introduction to the Relational Model.ppt
- 《数据库系统概念 Database System Concepts》原书教学资源(第六版,PPT课件讲稿,英文版)Chapter 20 Data Analysis.ppt
- 《数据库系统概念 Database System Concepts》原书教学资源(第六版,PPT课件讲稿,英文版)Chapter 21 Information Retrieval.ppt
- 《数据库系统概念 Database System Concepts》原书教学资源(第六版,PPT课件讲稿,英文版)Chapter 22 Object-Based Databases.ppt
- 《数据库系统概念 Database System Concepts》原书教学资源(第六版,PPT课件讲稿,英文版)Chapter 23 XML.ppt
- 《数据库系统概念 Database System Concepts》原书教学资源(第六版,PPT课件讲稿,英文版)Chapter 24 Advanced Application Development.ppt
- 《数据库系统概念 Database System Concepts》原书教学资源(第六版,PPT课件讲稿,英文版)Chapter 25 Advanced Data Types and New Applications.ppt
- 《数据库系统概念 Database System Concepts》原书教学资源(第六版,PPT课件讲稿,英文版)Chapter 26 Advanced Transaction Processing.ppt
- 《数据库系统概念 Database System Concepts》原书教学资源(第六版,PPT课件讲稿,英文版)Chapter 3 Introduction to SQL.ppt
- 《数据库系统概念 Database System Concepts》原书教学资源(第六版,PPT课件讲稿,英文版)Chapter 4 Intermediate SQL.ppt
- 《数据库系统概念 Database System Concepts》原书教学资源(第六版,PPT课件讲稿,英文版)Chapter 5 Advanced SQL.ppt
- 《数据库系统概念 Database System Concepts》原书教学资源(第六版,PPT课件讲稿,英文版)Chapter 6 Formal Relational Query Languages.ppt
- 《数据库系统概念 Database System Concepts》原书教学资源(第六版,PPT课件讲稿,英文版)Chapter 7 Database Design - The Entity-Relationship Approach.ppt
- 《数据库系统概念 Database System Concepts》原书教学资源(第六版,PPT课件讲稿,英文版)Chapter 8 Relational Database Design.ppt