SlideShare uma empresa Scribd logo
1 de 30
G.H Patel College of Engineering and 
Technology 
Department Of Computer Engineering 
DATABASE MANGMENT SYSTEM (2130703)
• QUERY EVALUATION PLAN 
G.H Patel College of Engg and Technology, Department Of Computer Engineering 2
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
• 
G.H Patel College of Engg and Technology, Department Of Computer Engineering 4
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
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
• 
• 
• 
• 
• 
G.H Patel College of Engg and Technology, Department Of Computer Engineering 7
• 
• 
G.H Patel College of Engg and Technology, Department Of Computer Engineering 8
• 
• 
• 
G.H Patel College of Engg and Technology, Department Of Computer Engineering 9
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
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
• 
• 
• 
• 
G.H Patel College of Engg and Technology, Department Of Computer Engineering 12
G.H Patel College of Engg and Technology, Department Of Computer Engineering 13
• 
• 
• 
• 
• 
• 
G.H Patel College of Engg and Technology, Department Of Computer Engineering 14
• 
• 
• 
• 
• 
G.H Patel College of Engg and Technology, Department Of Computer Engineering 15
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
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
• 
• QUERY EVALUATION PLANS 
• 
• 
• 
• QUERY OPTIMIZATION. 
G.H Patel College of Engg and Technology, Department Of Computer Engineering 18
• CLUSTERING INDEX 
• "PRIMARY" 
• NON-CLUSTERING INDEX 
• "SECONDARY" 
G.H Patel College of Engg and Technology, Department Of Computer Engineering 19
EMPLOYEES 
MAINTENANCES 
• 
• 
• 
• 1000 
• 
• 
• 
• 500 
G.H Patel College of Engg and Technology, Department Of Computer Engineering 20
R.ATTR = VALUE (R) 
• 
• 
• 
• 
• 
R.ATTR < VALUE (R) 
• WHY? 
• 
G.H Patel College of Engg and Technology, Department Of Computer Engineering 21
• 
• THAT’S EASY 
• 
• THIS IS MORE EXPENSIVE 
• 
• 
G.H Patel College of Engg and Technology, Department Of Computer Engineering 22
• 
• 
INDEX NESTED LOOPS JOIN 
• SIN 
• 
• ANALYSIS 
• 
• 
• 300,000 I/OS 
G.H Patel College of Engg and Technology, Department Of Computer Engineering 23
SORT-MERGE 
• 
• ANALYSIS 
• MAINTENANCES EMPLOYEES 
• 
• MAINTENANCES 
• EMPLOYEES 
• 
• (MUCH BETTER!!) 
G.H Patel College of Engg and Technology, Department Of Computer Engineering 24
• 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
• 
• MAINTENANCES EMPLOYEES 
• MAINTENANCES 
• 
G.H Patel College of Engg and Technology, Department Of Computer Engineering 26
• 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
• 
• 
G.H Patel College of Engg and Technology, Department Of Computer Engineering 28
G.H Patel College of Engg and Technology, Department Of Computer Engineering 29
Evaluation of Expression in Query Processing

Mais conteúdo relacionado

Mais procurados

17. Recovery System in DBMS
17. Recovery System in DBMS17. Recovery System in DBMS
17. Recovery System in DBMS
koolkampus
 
Unit 5 I/O organization
Unit 5   I/O organizationUnit 5   I/O organization
Unit 5 I/O organization
chidabdu
 
daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy method
hodcsencet
 

Mais procurados (20)

design of accumlator
design of accumlatordesign of accumlator
design of accumlator
 
Semophores and it's types
Semophores and it's typesSemophores and it's types
Semophores and it's types
 
Algorithm and pseudocode conventions
Algorithm and pseudocode conventionsAlgorithm and pseudocode conventions
Algorithm and pseudocode conventions
 
Pipelining & All Hazards Solution
Pipelining  & All Hazards SolutionPipelining  & All Hazards Solution
Pipelining & All Hazards Solution
 
Interrupts on 8086 microprocessor by vijay kumar.k
Interrupts on 8086 microprocessor by vijay kumar.kInterrupts on 8086 microprocessor by vijay kumar.k
Interrupts on 8086 microprocessor by vijay kumar.k
 
Operating System-Process Scheduling
Operating System-Process SchedulingOperating System-Process Scheduling
Operating System-Process Scheduling
 
Congetion Control.pptx
Congetion Control.pptxCongetion Control.pptx
Congetion Control.pptx
 
Cache memory
Cache memoryCache memory
Cache memory
 
Real-Time Scheduling
Real-Time SchedulingReal-Time Scheduling
Real-Time Scheduling
 
17. Recovery System in DBMS
17. Recovery System in DBMS17. Recovery System in DBMS
17. Recovery System in DBMS
 
Error Detection And Correction
Error Detection And CorrectionError Detection And Correction
Error Detection And Correction
 
Disk Scheduling Algorithm in Operating System
Disk Scheduling Algorithm in Operating SystemDisk Scheduling Algorithm in Operating System
Disk Scheduling Algorithm in Operating System
 
Unit 5 I/O organization
Unit 5   I/O organizationUnit 5   I/O organization
Unit 5 I/O organization
 
Flow control in Computer Network
Flow control in Computer NetworkFlow control in Computer Network
Flow control in Computer Network
 
daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy method
 
Stack organization
Stack organizationStack organization
Stack organization
 
Huffman coding
Huffman coding Huffman coding
Huffman coding
 
Pipeline processing and space time diagram
Pipeline processing and space time diagramPipeline processing and space time diagram
Pipeline processing and space time diagram
 
Paging and segmentation
Paging and segmentationPaging and segmentation
Paging and segmentation
 
Dining Philosopher Problem
Dining Philosopher ProblemDining Philosopher Problem
Dining Philosopher Problem
 

Destaque (6)

Schemaless Databases
Schemaless DatabasesSchemaless Databases
Schemaless Databases
 
Query Processing and Optimisation - Lecture 10 - Introduction to Databases (1...
Query Processing and Optimisation - Lecture 10 - Introduction to Databases (1...Query Processing and Optimisation - Lecture 10 - Introduction to Databases (1...
Query Processing and Optimisation - Lecture 10 - Introduction to Databases (1...
 
Cultivation theory
Cultivation theoryCultivation theory
Cultivation theory
 
Introduction to Graph Databases
Introduction to Graph DatabasesIntroduction to Graph Databases
Introduction to Graph Databases
 
Materials handling
Materials handlingMaterials handling
Materials handling
 
Green house ppt
Green house pptGreen house ppt
Green house ppt
 

Semelhante a Evaluation of Expression in Query Processing

Application of or for industrial engineers
Application of or for industrial engineersApplication of or for industrial engineers
Application of or for industrial engineers
Hakeem-Ur- Rehman
 
Resume - Balaji. P
Resume - Balaji. PResume - Balaji. P
Resume - Balaji. P
Balaji P
 

Semelhante a Evaluation of Expression in Query Processing (20)

Application of or for industrial engineers
Application of or for industrial engineersApplication of or for industrial engineers
Application of or for industrial engineers
 
Boetticher Presentation Promise 2008v2
Boetticher Presentation Promise 2008v2Boetticher Presentation Promise 2008v2
Boetticher Presentation Promise 2008v2
 
Assessing the Reliability of a Human Estimator
Assessing the Reliability of a Human EstimatorAssessing the Reliability of a Human Estimator
Assessing the Reliability of a Human Estimator
 
Optimization of process parameter for maximizing Material removal rate in tur...
Optimization of process parameter for maximizing Material removal rate in tur...Optimization of process parameter for maximizing Material removal rate in tur...
Optimization of process parameter for maximizing Material removal rate in tur...
 
CS8080_IRT_UNIT - III T8 FEATURE SELECTION OR DIMENSIONALITY REDUCTION.pdf
CS8080_IRT_UNIT - III T8  FEATURE SELECTION OR DIMENSIONALITY REDUCTION.pdfCS8080_IRT_UNIT - III T8  FEATURE SELECTION OR DIMENSIONALITY REDUCTION.pdf
CS8080_IRT_UNIT - III T8 FEATURE SELECTION OR DIMENSIONALITY REDUCTION.pdf
 
Functional verification techniques EW16 session
Functional verification techniques  EW16 sessionFunctional verification techniques  EW16 session
Functional verification techniques EW16 session
 
Multi-Response Optimization of Aluminum alloy using GRA & PCA by employing Ta...
Multi-Response Optimization of Aluminum alloy using GRA & PCA by employing Ta...Multi-Response Optimization of Aluminum alloy using GRA & PCA by employing Ta...
Multi-Response Optimization of Aluminum alloy using GRA & PCA by employing Ta...
 
M.tech. mechanical engineering 2016 17
M.tech. mechanical engineering 2016 17M.tech. mechanical engineering 2016 17
M.tech. mechanical engineering 2016 17
 
MySQL Optimizer Overview
MySQL Optimizer OverviewMySQL Optimizer Overview
MySQL Optimizer Overview
 
Derivación y aplicación de un Modelo de Estimación de Costos para la Ingenier...
Derivación y aplicación de un Modelo de Estimación de Costos para la Ingenier...Derivación y aplicación de un Modelo de Estimación de Costos para la Ingenier...
Derivación y aplicación de un Modelo de Estimación de Costos para la Ingenier...
 
JavaMicroBenchmarkpptm
JavaMicroBenchmarkpptmJavaMicroBenchmarkpptm
JavaMicroBenchmarkpptm
 
Resume - Balaji. P
Resume - Balaji. PResume - Balaji. P
Resume - Balaji. P
 
CSEG1001Unit 2 C Programming Fundamentals
CSEG1001Unit 2 C Programming FundamentalsCSEG1001Unit 2 C Programming Fundamentals
CSEG1001Unit 2 C Programming Fundamentals
 
Imitation Learning
Imitation LearningImitation Learning
Imitation Learning
 
Using Bayesian Optimization to Tune Machine Learning Models
Using Bayesian Optimization to Tune Machine Learning ModelsUsing Bayesian Optimization to Tune Machine Learning Models
Using Bayesian Optimization to Tune Machine Learning Models
 
Using Bayesian Optimization to Tune Machine Learning Models
Using Bayesian Optimization to Tune Machine Learning ModelsUsing Bayesian Optimization to Tune Machine Learning Models
Using Bayesian Optimization to Tune Machine Learning Models
 
Establishing A Defect Prediction Model Using A Combination of Product Metrics...
Establishing A Defect Prediction Model Using A Combination of Product Metrics...Establishing A Defect Prediction Model Using A Combination of Product Metrics...
Establishing A Defect Prediction Model Using A Combination of Product Metrics...
 
Control systems Unit-I (Dr.D.Lenine, RGMCET, Nandyal)
Control systems Unit-I (Dr.D.Lenine, RGMCET, Nandyal)Control systems Unit-I (Dr.D.Lenine, RGMCET, Nandyal)
Control systems Unit-I (Dr.D.Lenine, RGMCET, Nandyal)
 
Transfer defect learning
Transfer defect learningTransfer defect learning
Transfer defect learning
 
Benchmarks
BenchmarksBenchmarks
Benchmarks
 

Último

Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
dollysharma2066
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
dharasingh5698
 

Último (20)

Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdf
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 

Evaluation of Expression in Query Processing

  • 1. G.H Patel College of Engineering and Technology Department Of Computer Engineering DATABASE MANGMENT SYSTEM (2130703)
  • 2. • QUERY EVALUATION PLAN G.H Patel College of Engg and Technology, Department Of Computer Engineering 2
  • 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. • G.H Patel College of Engg and Technology, Department Of Computer Engineering 4
  • 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. 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. • • • • • G.H Patel College of Engg and Technology, Department Of Computer Engineering 7
  • 8. • • G.H Patel College of Engg and Technology, Department Of Computer Engineering 8
  • 9. • • • G.H Patel College of Engg and Technology, Department Of Computer Engineering 9
  • 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. 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. • • • • G.H Patel College of Engg and Technology, Department Of Computer Engineering 12
  • 13. G.H Patel College of Engg and Technology, Department Of Computer Engineering 13
  • 14. • • • • • • G.H Patel College of Engg and Technology, Department Of Computer Engineering 14
  • 15. • • • • • G.H Patel College of Engg and Technology, Department Of Computer Engineering 15
  • 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. 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. • • QUERY EVALUATION PLANS • • • • QUERY OPTIMIZATION. G.H Patel College of Engg and Technology, Department Of Computer Engineering 18
  • 19. • CLUSTERING INDEX • "PRIMARY" • NON-CLUSTERING INDEX • "SECONDARY" G.H Patel College of Engg and Technology, Department Of Computer Engineering 19
  • 20. EMPLOYEES MAINTENANCES • • • • 1000 • • • • 500 G.H Patel College of Engg and Technology, Department Of Computer Engineering 20
  • 21. R.ATTR = VALUE (R) • • • • • R.ATTR < VALUE (R) • WHY? • G.H Patel College of Engg and Technology, Department Of Computer Engineering 21
  • 22. • • THAT’S EASY • • THIS IS MORE EXPENSIVE • • G.H Patel College of Engg and Technology, Department Of Computer Engineering 22
  • 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. SORT-MERGE • • ANALYSIS • MAINTENANCES EMPLOYEES • • MAINTENANCES • EMPLOYEES • • (MUCH BETTER!!) G.H Patel College of Engg and Technology, Department Of Computer Engineering 24
  • 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. • • MAINTENANCES EMPLOYEES • MAINTENANCES • G.H Patel College of Engg and Technology, Department Of Computer Engineering 26
  • 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. • • G.H Patel College of Engg and Technology, Department Of Computer Engineering 28
  • 29. G.H Patel College of Engg and Technology, Department Of Computer Engineering 29