Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.
Prochain SlideShare
Chargement dans…5
×

# Evaluation of Expression in Query Processing

545 vues

Publié le

This Presentation is on the topic of Evaluation of Expression under Query Processing In the area of Database Management System of Computer Engineering.

Publié dans : Ingénierie
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Soyez le premier à commenter

### Evaluation of Expression in Query Processing

1. 1. G.H Patel College of Engineering and Technology Department Of Computer Engineering DATABASE MANGMENT SYSTEM (2130703)
2. 2. • QUERY EVALUATION PLAN G.H Patel College of Engg and Technology, Department Of Computer Engineering 2
3. 3. ename (on the fly) planeId=100 AND rating>5 (on the fly) (nested loops) (file scan) Employees Maintenances (file scan) Method to use Sometimes it might be possible, to pipeline the result of one operator to another operator without creating a temporary table for the intermediate result. This saves in cost. When the input to a unary operator (e.g.  or ) is pipelined into it, we say the operator is applied on-the-fly. G.H Patel College of Engg and Technology, Department Of Computer Engineering 3
4. 4. • G.H Patel College of Engg and Technology, Department Of Computer Engineering 4
5. 5. ename (on the fly) planeId=100 AND rating>5 (on the fly) Maintenances (file scan) (nested loops join) Employees (file scan) Cost for this plan: 300,000 I/Os for the join.  and  are done in the fly; no I/O cost for them. G.H Patel College of Engg and Technology, Department Of Computer Engineering 5
6. 6. ename (on the fly) planeId=100 AND rating>5 (on the fly) Maintenances (file scan) (sort merge join) Employees (file scan) Cost for this plan: 7,500 I/Os for the join.  and  are done in the fly; no I/O cost for them. G.H Patel College of Engg and Technology, Department Of Computer Engineering 6
7. 7. • • • • • G.H Patel College of Engg and Technology, Department Of Computer Engineering 7
8. 8. • • G.H Patel College of Engg and Technology, Department Of Computer Engineering 8
9. 9. • • • G.H Patel College of Engg and Technology, Department Of Computer Engineering 9
10. 10. FOR EXAMPLE: SELECT * FROM STAFF WHERE ID = (SELECT MAX(MANAGER) FROM ORG) IN THIS STATEMENT, THE SUBQUERY NEEDS TO BE EVALUATED ONLY ONCE. THIS TYPE OF SUBQUERY MUST RETURN ONLY ONE ROW. IF EVALUATING THE SUBQUERY CAUSES A CARDINALITY VIOLATION (IF IT RETURNS MORE THAN ONE ROW), AN EXCEPTION IS THROWN WHEN THE SUBQUERY IS RUN. G.H Patel College of Engg and Technology, Department Of Computer Engineering 10
11. 11. SUBQUERY MATERIALIZATION IS DETECTED BEFORE OPTIMIZATION, WHICH ALLOWS THE DERBY OPTIMIZER TO SEE A MATERIALIZED SUBQUERY AS AN UNKNOWN CONSTANT VALUE. THE COMPARISON IS THEREFORE OPTIMIZABLE. THE ORIGINAL STATEMENT IS TRANSFORMED INTO THE FOLLOWING TWO STATEMENTS: CONSTANT = SELECT MAX(MANAGER) FROM ORG SELECT * FROM STAFF WHERE ID = CONSTANT THE SECOND STATEMENT IS OPTIMIZABLE. G.H Patel College of Engg and Technology, Department Of Computer Engineering 11
12. 12. • • • • G.H Patel College of Engg and Technology, Department Of Computer Engineering 12
13. 13. G.H Patel College of Engg and Technology, Department Of Computer Engineering 13
14. 14. • • • • • • G.H Patel College of Engg and Technology, Department Of Computer Engineering 14
15. 15. • • • • • G.H Patel College of Engg and Technology, Department Of Computer Engineering 15
16. 16. Employees (sin INT, ename VARCHAR(20), rating INT, age REAL) Maintenances (sin INT, planeId INT, day DATE, descCode CHAR(10)) SELECT ename FROM Employees NATURAL JOIN Maintenances WHERE planeId = 100 AND rating > 5; ename (planeId=100 AND rating>5 (Employees Maintenances)) G.H Patel College of Engg and Technology, Department Of Computer Engineering 16
17. 17. ename planeId=100 AND rating>5 RA expressions can are represented by an expression tree. Maintenances Employees An algorithm is chosen for each node in the expression tree. G.H Patel College of Engg and Technology, Department Of Computer Engineering 17
18. 18. • • QUERY EVALUATION PLANS • • • • QUERY OPTIMIZATION. G.H Patel College of Engg and Technology, Department Of Computer Engineering 18
19. 19. • CLUSTERING INDEX • "PRIMARY" • NON-CLUSTERING INDEX • "SECONDARY" G.H Patel College of Engg and Technology, Department Of Computer Engineering 19
20. 20. EMPLOYEES MAINTENANCES • • • • 1000 • • • • 500 G.H Patel College of Engg and Technology, Department Of Computer Engineering 20
21. 21. R.ATTR = VALUE (R) • • • • • R.ATTR < VALUE (R) • WHY? • G.H Patel College of Engg and Technology, Department Of Computer Engineering 21
22. 22. • • THAT’S EASY • • THIS IS MORE EXPENSIVE • • G.H Patel College of Engg and Technology, Department Of Computer Engineering 22
23. 23. • • INDEX NESTED LOOPS JOIN • SIN • • ANALYSIS • • • 300,000 I/OS G.H Patel College of Engg and Technology, Department Of Computer Engineering 23
24. 24. SORT-MERGE • • ANALYSIS • MAINTENANCES EMPLOYEES • • MAINTENANCES • EMPLOYEES • • (MUCH BETTER!!) G.H Patel College of Engg and Technology, Department Of Computer Engineering 24
25. 25. • INDEX NESTED LOOPS JOIN • SORT-MERGE JOIN • WHY BOTHER WITH INDEX NESTED LOOPS JOIN? • INDEX NESTED LOOPS • MAINTENANCES • MAINTENANCES MAINTENANCES EMPLOYEES G.H Patel College of Engg and Technology, Department Of Computer Engineering 25
26. 26. • • MAINTENANCES EMPLOYEES • MAINTENANCES • G.H Patel College of Engg and Technology, Department Of Computer Engineering 26
27. 27. • OBSERVE THAT THE CHOICE OF INDEX NESTED LOOPS JOIN IS BASED ON CONSIDERING THE QUERY AS A WHOLE, INCLUDING THE EXTRA SELECTION ON MAINTENANCES, RATHER THAN JUST THE JOIN OPERATION BY ITSELF. • QUERY OPTIMIZATION • G.H Patel College of Engg and Technology, Department Of Computer Engineering 27
28. 28. • • G.H Patel College of Engg and Technology, Department Of Computer Engineering 28
29. 29. G.H Patel College of Engg and Technology, Department Of Computer Engineering 29