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

Chapter 12:Query Processing Overview Measures of Query Cost Selection Operation Sorting Join Operation Other Operations Evaluation of Expressions Database System Concepts -6th Edition 12.2 ©Silberschat乜,Korth and Sudarshan
Database System Concepts - 6 12.2 ©Silberschatz, Korth and Sudarshan th Edition Chapter 12: Query Processing Overview Measures of Query Cost Selection Operation Sorting Join Operation Other Operations Evaluation of Expressions

Basic Steps in Query Processing 1.Parsing and translation 2.Optimization 3.Evaluation parser and relational-algebra query translator expression optimizer query output evaluation engine execution plan data statistics about data Database System Concepts-6th Edition 12.3 ©Silberschat乜,Korth and Sudarshan
Database System Concepts - 6 12.3 ©Silberschatz, Korth and Sudarshan th Edition Basic Steps in Query Processing 1. Parsing and translation 2. Optimization 3. Evaluation

Basic Steps in Query Processing (Cont.) Parsing and translation translate the query into its internal form.This is then translated into relational algebra. Parser checks syntax,verifies relations Evaluation The query-execution engine takes a query-evaluation plan, executes that plan,and returns the answers to the query. Database System Concepts-6th Edition 12.4 ©Silberschat乜,Korth and Sudarshan
Database System Concepts - 6 12.4 ©Silberschatz, Korth and Sudarshan th Edition Basic Steps in Query Processing (Cont.) Parsing and translation translate the query into its internal form. This is then translated into relational algebra. Parser checks syntax, verifies relations Evaluation The query-execution engine takes a query-evaluation plan, executes that plan, and returns the answers to the query

Basic Steps in Query Processing Optimization A relational algebra expression may have many equivalent expressions E.g.,salary<75000(Isalary(instructor)is equivalent to IIsalary (Osalary<75000(instructor) Each relational algebra operation can be evaluated using one of several different algorithms Correspondingly,a relational-algebra expression can be evaluated in many ways. Annotated expression specifying detailed evaluation strategy is called an evaluation-plan. E.g.,can use an index on salary to find instructors with salary 75000, or can perform complete relation scan and discard instructors with salary≥75000 Database System Concepts-6th Edition 12.5 ©Silberschat乜,Korth and Sudarshan
Database System Concepts - 6 12.5 ©Silberschatz, Korth and Sudarshan th Edition Basic Steps in Query Processing : Optimization A relational algebra expression may have many equivalent expressions E.g., salary75000(salary(instructor)) is equivalent to salary(salary75000(instructor)) Each relational algebra operation can be evaluated using one of several different algorithms Correspondingly, a relational-algebra expression can be evaluated in many ways. Annotated expression specifying detailed evaluation strategy is called an evaluation-plan. E.g., can use an index on salary to find instructors with salary < 75000, or can perform complete relation scan and discard instructors with salary 75000

Basic Steps:Optimization(Cont.) Query Optimization:Amongst all equivalent evaluation plans choose the one with lowest cost. Cost is estimated using statistical information from the database catalog e.g.number of tuples in each relation,size of tuples,etc. In this chapter we study How to measure query costs Algorithms for evaluating relational algebra operations How to combine algorithms for individual operations in order to evaluate a complete expression In Chapter 14 We study how to optimize queries,that is,how to find an evaluation plan with lowest estimated cost Database System Concepts-6th Edition 12.6 ©Silberschat乜,Korth and Sudarshan
Database System Concepts - 6 12.6 ©Silberschatz, Korth and Sudarshan th Edition Basic Steps: Optimization (Cont.) Query Optimization: Amongst all equivalent evaluation plans choose the one with lowest cost. Cost is estimated using statistical information from the database catalog e.g. number of tuples in each relation, size of tuples, etc. In this chapter we study How to measure query costs Algorithms for evaluating relational algebra operations How to combine algorithms for individual operations in order to evaluate a complete expression In Chapter 14 We study how to optimize queries, that is, how to find an evaluation plan with lowest estimated cost

Measures of Query Cost Cost is generally measured as total elapsed time for answering query Many factors contribute to time cost disk accesses,CPU,or even network communication Typically disk access is the predominant cost,and is also relatively easy to estimate.Measured by taking into account Number of seeks average-seek-cost Number of blocks read average-block-read-cost Number of blocks written average-block-write-cost Cost to write a block is greater than cost to read a block data is read back after being written to ensure that the write was successful Database System Concepts-6th Edition 12.7 ©Silberschat乜,Korth and Sudarshan
Database System Concepts - 6 12.7 ©Silberschatz, Korth and Sudarshan th Edition Measures of Query Cost Cost is generally measured as total elapsed time for answering query Many factors contribute to time cost disk accesses, CPU, or even network communication Typically disk access is the predominant cost, and is also relatively easy to estimate. Measured by taking into account Number of seeks * average-seek-cost Number of blocks read * average-block-read-cost Number of blocks written * average-block-write-cost Cost to write a block is greater than cost to read a block – data is read back after being written to ensure that the write was successful

Measures of Query Cost(Cont.) For simplicity we just use the number of block transfers from disk and the number of seeks as the cost measures -time to transfer one block ts-time for one seek Cost for b block transfers plus S seeks b *t+S *ts We ignore CPU costs for simplicity Real systems do take CPU cost into account We do not include cost to writing output to disk in our cost formulae Database System Concepts-6th Edition 12.8 @Silberschatz,Korth and Sudarshan
Database System Concepts - 6 12.8 ©Silberschatz, Korth and Sudarshan th Edition Measures of Query Cost (Cont.) For simplicity we just use the number of block transfers from disk and the number of seeks as the cost measures tT – time to transfer one block tS – time for one seek Cost for b block transfers plus S seeks b * tT + S * tS We ignore CPU costs for simplicity Real systems do take CPU cost into account We do not include cost to writing output to disk in our cost formulae

Measures of Query Cost(Cont.) Several algorithms can reduce disk IO by using extra buffer space Amount of real memory available to buffer depends on other concurrent queries and OS processes,known only during execution We often use worst case estimates,assuming only the minimum amount of memory needed for the operation is available Required data may be buffer resident already,avoiding disk I/O But hard to take into account for cost estimation Database System Concepts-6th Edition 12.9 @Silberschatz,Korth and Sudarshan
Database System Concepts - 6 12.9 ©Silberschatz, Korth and Sudarshan th Edition Measures of Query Cost (Cont.) Several algorithms can reduce disk IO by using extra buffer space Amount of real memory available to buffer depends on other concurrent queries and OS processes, known only during execution We often use worst case estimates, assuming only the minimum amount of memory needed for the operation is available Required data may be buffer resident already, avoiding disk I/O But hard to take into account for cost estimation

Selection Operation File scan Algorithm A1 (linear search).Scan each file block and test all records to see whether they satisfy the selection condition. Cost estimate=b,block transfers +1 seek b,denotes number of blocks containing records from relation r If selection is on a key attribute,can stop on finding record cost=(b,/2)block transfers +1 seek Linear search can be applied regardless of selection condition or ordering of records in the file,or availability of indices Note:binary search generally does not make sense since data is not stored consecutively except when there is an index available, and binary search requires more seeks than index search Database System Concepts-6th Edition 12.10 ©Silberschat乜,Korth and Sudarshan
Database System Concepts - 6 12.10 ©Silberschatz, Korth and Sudarshan th Edition Selection Operation File scan Algorithm A1 (linear search). Scan each file block and test all records to see whether they satisfy the selection condition. Cost estimate = br block transfers + 1 seek br denotes number of blocks containing records from relation r If selection is on a key attribute, can stop on finding record cost = (br /2) block transfers + 1 seek Linear search can be applied regardless of selection condition or ordering of records in the file, or availability of indices Note: binary search generally does not make sense since data is not stored consecutively except when there is an index available, and binary search requires more seeks than index search

Selections Using Indices Index scan-search algorithms that use an index selection condition must be on search-key of index. A2(primary index,equality on key).Retrieve a single record that satisfies the corresponding equality condition Cost=(hi+1)(t+ts) A3(primary index,equality on nonkey)Retrieve multiple records. Records will be on consecutive blocks Let b number of blocks containing matching records Cost=hi *(tT+ts)+ts+t*b Database System Concepts-6th Edition 12.11 @Silberschatz,Korth and Sudarshan
Database System Concepts - 6 12.11 ©Silberschatz, Korth and Sudarshan th Edition Selections Using Indices Index scan – search algorithms that use an index selection condition must be on search-key of index. A2 (primary index, equality on key). Retrieve a single record that satisfies the corresponding equality condition Cost = (hi + 1) * (tT + tS) A3 (primary index, equality on nonkey) Retrieve multiple records. Records will be on consecutive blocks Let b = number of blocks containing matching records Cost = hi * (tT + tS ) + tS + tT * b
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 《数据库系统概念 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
- RFID标签识别机制-冲突以及防冲突算法研究(参考文献)P-MTI - Physical-layer Missing Tag Identification via Compressive Sensing.pdf
- 《数据库系统概念 Database System Concepts》原书教学资源(第六版,PPT课件讲稿,英文版)Chapter 13 Query Optimization.ppt
- 《数据库系统概念 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