山东大学数据库系统英语课件13查询优化

上传人:东*** 文档编号:279774407 上传时间:2022-04-20 格式:PPT 页数:80 大小:1.43MB
返回 下载 相关 举报
山东大学数据库系统英语课件13查询优化_第1页
第1页 / 共80页
山东大学数据库系统英语课件13查询优化_第2页
第2页 / 共80页
山东大学数据库系统英语课件13查询优化_第3页
第3页 / 共80页
山东大学数据库系统英语课件13查询优化_第4页
第4页 / 共80页
山东大学数据库系统英语课件13查询优化_第5页
第5页 / 共80页
点击查看更多>>
资源描述

《山东大学数据库系统英语课件13查询优化》由会员分享,可在线阅读,更多相关《山东大学数据库系统英语课件13查询优化(80页珍藏版)》请在金锄头文库上搜索。

1、Database System Concepts, 6th Ed.Silberschatz, Korth and SudarshanSee www.db- for conditions on re-use Chapter 13: Query OptimizationSilberschatz, Korth and Sudarshan1.2Database System Concepts - 6th EditionChapter 13: Query OptimizationnIntroduction nTransformation of Relational ExpressionsnCatalog

2、 Information for Cost EstimationnStatistical Information for Cost EstimationnCost-based optimizationnDynamic Programming for Choosing Evaluation PlansnMaterialized views Silberschatz, Korth and Sudarshan1.3Database System Concepts - 6th EditionIntroductionnAlternative ways of evaluating a given quer

3、ylEquivalent expressionslDifferent algorithms for each operationSilberschatz, Korth and Sudarshan1.4Database System Concepts - 6th EditionIntroduction (Cont.)nAn evaluation plan defines exactly what algorithm is used for each operation, and how the execution of the operations is coordinated.nFind ou

4、t how to view query execution plans on your favorite databaseSilberschatz, Korth and Sudarshan1.5Database System Concepts - 6th EditionIntroduction (Cont.)nCost difference between evaluation plans for a query can be enormouslE.g. seconds vs. days in some casesnSteps in cost-based query optimization1

5、.Generate logically equivalent expressions using equivalence rules2.Annotate resultant expressions to get alternative query plans3.Choose the cheapest plan based on estimated costnEstimation of plan cost based on:lStatistical information about relations. Examples:4number of tuples, number of distinc

6、t values for an attributelStatistics estimation for intermediate results4to compute cost of complex expressionslCost formulae for algorithms, computed using statisticsDatabase System Concepts, 6th Ed.Silberschatz, Korth and SudarshanSee www.db- for conditions on re-use Generating Equivalent Expressi

7、onsSilberschatz, Korth and Sudarshan1.7Database System Concepts - 6th EditionTransformation of Relational ExpressionsnTwo relational algebra expressions are said to be equivalent if the two expressions generate the same set of tuples on every legal database instancelNote: order of tuples is irreleva

8、ntlwe dont care if they generate different results on databases that violate integrity constraintsnIn SQL, inputs and outputs are multisets of tupleslTwo expressions in the multiset version of the relational algebra are said to be equivalent if the two expressions generate the same multiset of tuple

9、s on every legal database instance. nAn equivalence rule says that expressions of two forms are equivalentlCan replace expression of first form by second, or vice versaSilberschatz, Korth and Sudarshan1.8Database System Concepts - 6th EditionEquivalence Rules1. Conjunctive selection operations can b

10、e 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

11、 E2 Silberschatz, Korth and Sudarshan1.9Database System Concepts - 6th EditionEquivalence Rules (Cont.)5. Theta-join operations (and natural joins) are commutative.E1 E2 = E2 E16. (a) Natural join operations are associative: (E1 E2) E3 = E1 (E2 E3)(b) Theta joins are associative in the following man

12、ner: (E1 1 E2) 2 3 E3 = E1 1 3 (E2 2 E3) where 2 involves attributes from only E2 and E3.Silberschatz, Korth and Sudarshan1.10Database System Concepts - 6th EditionPictorial Depiction of Equivalence RulesSilberschatz, Korth and Sudarshan1.11Database System Concepts - 6th EditionEquivalence Rules (Co

13、nt.)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. 0E1 E2) = (0(E1) E2 (b) When 1 involves only the attributes of E1 and 2 involves only t

14、he attributes of E2. 1 E1 E2) = (1(E1) ( (E2)Silberschatz, Korth and Sudarshan1.12Database System Concepts - 6th EditionEquivalence Rules (Cont.)8.The projection operation distributes over the theta join operation as follows:(a) if involves only attributes from L1 L2:(b) Consider a join E1 E2. l Let

15、 L1 and L2 be sets of attributes from E1 and E2, respectively. lLet L3 be attributes of E1 that are involved in join condition , but are not in L1 L2, andl let L4 be attributes of E2 that are involved in join condition , but are not in L1 L2.)()()(21212121EEEELLLL=)()()(212142312121EEEELLLLLLLL=Silb

16、erschatz, Korth and Sudarshan1.13Database System Concepts - 6th EditionEquivalence Rules (Cont.)9.The set operations union and intersection are commutative E1 E2 = E2 E1 E1 E2 = E2 E1 9.(set difference is not commutative).10.Set union and intersection are associative. (E1 E2) E3 = E1 (E2 E3) (E1 E2) E3 = E1 (E2 E3)9.The selection operation distributes over , and . (E1 E2) = (E1) (E2) and similarly for and in place of Also: (E1 E2) = (E1) E2 and similarly for in place of , but not for 12. The pro

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > IT计算机/网络 > 数据库

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号