Chapter 15:Query Processing Overview Measures of Query Cost ■Selection Operation ■ Sorting ■Join Operation ■Other Operations Evaluation of Expressions Database System Concepts-7th Edition 15.2 @Silberschatz,Korth and Sudarshan
Database System Concepts - 7 15.2 ©Silberschatz, Korth and Sudarshan th Edition Chapter 15: 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 query parser and relational-algebra translator expression optimizer ! query evaluation engine output execution plan data statistics about data Database System Concepts-7th Edition 15.3 @Silberschatz,Korth and Sudarshan
Database System Concepts - 7 15.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-7th Edition 15.4 @Silberschatz,Korth and Sudarshan
Database System Concepts - 7 15.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.salary75000(saay(instructor))is equivalent to Πsalary(salary<75ooo(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.,: Use an index on salary to find instructors with salary 75000. Or perform complete relation scan and discard instructors with salary ≥75000 Database System Concepts-7th Edition 15.5 ©Silberscha乜,Korth and Sudarshan
Database System Concepts - 7 15.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.,: • Use an index on salary to find instructors with salary < 75000, • Or 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 16 We study how to optimize queries,that is,how to find an evaluation plan with lowest estimated cost Database System Concepts-7th Edition 15.6 ©Silberscha乜,Korth and Sudarshan
Database System Concepts - 7 15.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 16 • We study how to optimize queries, that is, how to find an evaluation plan with lowest estimated cost