Query Processing and Optimization
Query Processing and Optimization
GTU # 3130703
Unit-5
Query Processing
and Optimization
Outline
Looping
• Steps in query processing
• Measures of query cost
• Selection operation
• Evaluation of expressions
• Query optimization
• Transformation of relational expressions
• Sorting and join
Steps in query processing
Steps in Query Processing
Parser checks the syntax of Translator translates the
query and verifies attribute query into its internal
name and relation name form (relational algebra)
Database Catalog
Data Statistics about Data
Bottom to top
Execution
To evaluate such expression we need to
evaluate each operations one by one in
appropriate order. σBalance<2500 (customer)
Two methods for evaluating an expression
carrying multiple operations are:
Materialization
(account)
Pipelining
4 records 4 records
Customer
CID ANO Name Balance
σANO<3 (σBalance<2000 (Customer)) Output
C01 1 Raj 3000
CID ANO Name Balance
C02 2 Meet 1000 OUTPUT
C02 2 Meet 1000
C03 3 Jay 2000
C04 4 Ram 4000 σBalance<2000 (σANO<3 (Customer))
Customer Account
CID ANO Name ANO Balance
σANO<3 (Customer Account) Output
C01 1 Raj 1 3000 CID ANO Name Balance
C02 2 Meet 2 1000 OUTPUT C01 1 Raj 3000
C03 3 Jay 3 2000 C02 2 Meet 1000
C04 4 Ram 4 4000 (Customer) σANO<3 (Account)
Customer Account
CID ANO Name ANO Balance
(Account) σANO<3 (Customer) Output
C01 1 Raj 1 3000 CID ANO Name Balance
C02 2 Meet 2 1000 OUTPUT C01 1 Raj 3000
C03 3 Jay 3 2000 C02 2 Meet 1000
C04 4 Ram 4 4000 (Customer) σANO<3 (Account)
E1 σθ E2 = E2 σθ E1