SlideShare a Scribd company logo
1 of 18
QUERY PROCESSING AND
QUERY OPTIMIZATION
By NIRAJ GANDHA
What is Query Processing?
 It is a 3 step process that transforms a high level query
(sql) into an equivalent and more efficient lower-level
query (of relational algebra).
Query
Query
 Query is the statement written by the user in high language
using pl/sql.
Parser & Translator
Query
Parser
&
Translator
 Parser: Checks the syntax and verifies the relation.
 Translator: Translates the query into an equivalent
relational algebra.
Example:
SQL> select name from customer;
RA:=∏name(customer)
Relational Algebra
Query
Parser
&
Translator
Relational
Algebra
 It is the query converted in algebraic form from pl/ sql by
translator.
 Example:
SQL>SELECT ENAME FROM EMP,ASG WHERE
EMP.ENO=ASG.ENO AND DUR>37;
RA:1) ΠENAME(σDUR>37∧EMP.ENO=ASG.ENO(EMP × ASG))
2) ΠENAME(EMP ENO (σDUR>37(ASG)))
Optimizer
Query
Parser
&
Translator
Relational
Algebra
Optimizer
 It will select the query which has low cost.
Example:
1) ΠENAME(σDUR>37∧EMP.ENO=ASG.ENO(EMP × ASG))
2) ΠENAME(EMP ENO (σDUR>37(ASG)))
Optimizer will select Expression2 as it avoids
the expensive and large intermediate
Cartesian product, and therefore typically is
better.
Comparison of two relational queries
 ΠENAME(σDUR>37∧EMP.ENO=ASG.ENO
(EMP × ASG))
 ΠENAME(EMP ENO(σDUR>37(ASG)))
EMP x ASG
Temp as
EMP.ENO=ASG.ENO
ΠENAME
ENO(σDUR>37(ASG)
EMP ENO
ΠENAME
σDUR>37 ∧temp
Query
Parser
&
Translator
Relational
Algebra
Optimizer
Statistical
Data
Statistical Data
 A Statical Data is a
database used for
statistical analysis
purposes.
 It is an OLAP(Online
Analytical Processing),
instead of OLTP(Online
Transaction Processing)
system
Evaluation Plan
Query
Parser
&
Translator
Relational
Algebra
Optimizer
Statistical
Data
Evaluation
Plan
 Relational Algebra
annotated with instructions
on how to evaluate it is
called an evaluation
primitive.
 Sequence of primitive
operations that can be
used to evaluate a query is
a query evaluation plan.
EVALUATION & DATA
 The evaluation
engine takes
the evaluation
plan as
condition and
applies it on
the data.
Query
Parser
&
Translator
Relational
Algebra
Optimizer
Statistical
Data
Evaluation
Plan
Evaluation
 The information on
which the query has
to be performed is
called data.Data
OUTPUT
Query
Parser
&
Translator
Relational
Algebra
Optimizer
Statistical
Data
Evaluation
Plan
EvaluationOutput
Data
 After the evaluation of
plan on data,
processed information
is showed in output.
Diagram of Query Processing
Query
Parser
&
Translator
Relational
Algebra
Optimizer
Statistical
Data
Evaluation
Plan
EvaluationOutput
Data
Measures of Query Cost
 The cost of query evaluation can be measured in
terms of different resources, including
 disk accesses
 CPU time to execute a query in a distributed or
parallel database system
 the cost of communication.
Materialization
 In materialization approach, output of every single operation
is saved in temporary relation for the subsequent use.
 It starts from the lowest-level operations in the expression.
 Ex: Πcustomer(σbalance<2500(account) customer)
Πcustomer
σbalance<2500 customer
account
Pipelining
 In pipelining approach, output of every single operation is not
necessary to save in temporary relation for the subsequent
use.
 In this the operations take place simultaneously or in
background
 It starts from the lowest-level operations in the expression.
 Ex: Πcustomer(σbalance<2500(account) customer)
Πcustomer
σbalance<2500 customer
account
Query Optimization
 It is the process of selecting the most efficient query-
evaluation plan from among the many strategies usually
possible for processing a given query, especially if the query is
complex.
Example of Optimization
 ∏customer(σbranch_city=”Brooklyn”(branch
(account depositor)))
∏customer
σbranch_city=”Brooklyn”
branch
account depositor
 ∏customer((σbranch_city=”Brooklyn”(branc
h)) (account depositor))
∏customer
σbranch_city=”Brooklyn”
branch account depositor
The end

More Related Content

What's hot

Query-porcessing-& Query optimization
Query-porcessing-& Query optimizationQuery-porcessing-& Query optimization
Query-porcessing-& Query optimizationSaranya Natarajan
 
14. Query Optimization in DBMS
14. Query Optimization in DBMS14. Query Optimization in DBMS
14. Query Optimization in DBMSkoolkampus
 
Query Optimization
Query OptimizationQuery Optimization
Query Optimizationrohitsalunke
 
Query optimization
Query optimizationQuery optimization
Query optimizationNeha Behl
 
Query Optimization - Brandon Latronica
Query Optimization - Brandon LatronicaQuery Optimization - Brandon Latronica
Query Optimization - Brandon Latronica"FENG "GEORGE"" YU
 
Query optimization
Query optimizationQuery optimization
Query optimizationdixitdavey
 
Concurrency Control in Database Management System
Concurrency Control in Database Management SystemConcurrency Control in Database Management System
Concurrency Control in Database Management SystemJanki Shah
 
8 query processing and optimization
8 query processing and optimization8 query processing and optimization
8 query processing and optimizationKumar
 
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...Beat Signer
 
Query Decomposition and data localization
Query Decomposition and data localization Query Decomposition and data localization
Query Decomposition and data localization Hafiz faiz
 
Relational algebra ppt
Relational algebra pptRelational algebra ppt
Relational algebra pptGirdharRatne
 
Transaction management DBMS
Transaction  management DBMSTransaction  management DBMS
Transaction management DBMSMegha Patel
 
12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMS12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMSkoolkampus
 

What's hot (20)

Query-porcessing-& Query optimization
Query-porcessing-& Query optimizationQuery-porcessing-& Query optimization
Query-porcessing-& Query optimization
 
14. Query Optimization in DBMS
14. Query Optimization in DBMS14. Query Optimization in DBMS
14. Query Optimization in DBMS
 
Query Optimization
Query OptimizationQuery Optimization
Query Optimization
 
Query optimization
Query optimizationQuery optimization
Query optimization
 
Query Optimization - Brandon Latronica
Query Optimization - Brandon LatronicaQuery Optimization - Brandon Latronica
Query Optimization - Brandon Latronica
 
Query optimization
Query optimizationQuery optimization
Query optimization
 
Query optimization
Query optimizationQuery optimization
Query optimization
 
Concurrency Control in Database Management System
Concurrency Control in Database Management SystemConcurrency Control in Database Management System
Concurrency Control in Database Management System
 
8 query processing and optimization
8 query processing and optimization8 query processing and optimization
8 query processing and optimization
 
Deductive databases
Deductive databasesDeductive databases
Deductive databases
 
Query trees
Query treesQuery trees
Query trees
 
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...
 
Query Decomposition and data localization
Query Decomposition and data localization Query Decomposition and data localization
Query Decomposition and data localization
 
Joins in SQL
Joins in SQLJoins in SQL
Joins in SQL
 
Relational algebra ppt
Relational algebra pptRelational algebra ppt
Relational algebra ppt
 
Transaction management DBMS
Transaction  management DBMSTransaction  management DBMS
Transaction management DBMS
 
Database fragmentation
Database fragmentationDatabase fragmentation
Database fragmentation
 
Normalization in DBMS
Normalization in DBMSNormalization in DBMS
Normalization in DBMS
 
Semi join
Semi joinSemi join
Semi join
 
12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMS12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMS
 

Viewers also liked

Региональные и муниципальные информационные системы
Региональные и муниципальные информационные системыРегиональные и муниципальные информационные системы
Региональные и муниципальные информационные системыРаиса Шпакова
 
Artnet presentation2013
Artnet presentation2013Artnet presentation2013
Artnet presentation2013artnet1010
 
Начальная(максимальная) цена контракта. Методы расчета и обоснования
Начальная(максимальная) цена контракта. Методы расчета и обоснованияНачальная(максимальная) цена контракта. Методы расчета и обоснования
Начальная(максимальная) цена контракта. Методы расчета и обоснованияРаиса Шпакова
 
Benefits of biotin
Benefits of biotinBenefits of biotin
Benefits of biotinAlbert Green
 
20151107 workshop HPA, HLA, HEA genotype
20151107 workshop HPA, HLA, HEA genotype20151107 workshop HPA, HLA, HEA genotype
20151107 workshop HPA, HLA, HEA genotypeJhysheng Chang
 
evaluation of thrombocytopenia
evaluation of thrombocytopeniaevaluation of thrombocytopenia
evaluation of thrombocytopeniaJhysheng Chang
 
All about platelet immunology
All about platelet immunologyAll about platelet immunology
All about platelet immunologyJhysheng Chang
 
20140430l北捐auto anibody
20140430l北捐auto anibody20140430l北捐auto anibody
20140430l北捐auto anibodyJhysheng Chang
 

Viewers also liked (13)

Manual polybrene
Manual polybreneManual polybrene
Manual polybrene
 
Региональные и муниципальные информационные системы
Региональные и муниципальные информационные системыРегиональные и муниципальные информационные системы
Региональные и муниципальные информационные системы
 
Artnet presentation2013
Artnet presentation2013Artnet presentation2013
Artnet presentation2013
 
Начальная(максимальная) цена контракта. Методы расчета и обоснования
Начальная(максимальная) цена контракта. Методы расчета и обоснованияНачальная(максимальная) цена контракта. Методы расчета и обоснования
Начальная(максимальная) цена контракта. Методы расчета и обоснования
 
реестр договоров
реестр договоровреестр договоров
реестр договоров
 
Benefits of biotin
Benefits of biotinBenefits of biotin
Benefits of biotin
 
Msm for joints
Msm for jointsMsm for joints
Msm for joints
 
20151107 workshop HPA, HLA, HEA genotype
20151107 workshop HPA, HLA, HEA genotype20151107 workshop HPA, HLA, HEA genotype
20151107 workshop HPA, HLA, HEA genotype
 
evaluation of thrombocytopenia
evaluation of thrombocytopeniaevaluation of thrombocytopenia
evaluation of thrombocytopenia
 
Mp only 馬偕
Mp only 馬偕Mp only 馬偕
Mp only 馬偕
 
All about platelet immunology
All about platelet immunologyAll about platelet immunology
All about platelet immunology
 
Hpa antibody
Hpa antibodyHpa antibody
Hpa antibody
 
20140430l北捐auto anibody
20140430l北捐auto anibody20140430l北捐auto anibody
20140430l北捐auto anibody
 

Similar to Query processing and Query Optimization

Overview of query evaluation
Overview of query evaluationOverview of query evaluation
Overview of query evaluationavniS
 
Processes in Query Optimization in (ABMS) Advanced Database Management Systems
Processes in Query Optimization in (ABMS) Advanced Database Management Systems Processes in Query Optimization in (ABMS) Advanced Database Management Systems
Processes in Query Optimization in (ABMS) Advanced Database Management Systems gamemaker762
 
Implementation of query optimization for reducing run time
Implementation of query optimization for reducing run timeImplementation of query optimization for reducing run time
Implementation of query optimization for reducing run timeAlexander Decker
 
LECTURE_06_DATABASE PROCESSING & OPTIMAZATION.pptx
LECTURE_06_DATABASE PROCESSING & OPTIMAZATION.pptxLECTURE_06_DATABASE PROCESSING & OPTIMAZATION.pptx
LECTURE_06_DATABASE PROCESSING & OPTIMAZATION.pptxAthosBeatus
 
SQL Performance Tuning and New Features in Oracle 19c
SQL Performance Tuning and New Features in Oracle 19cSQL Performance Tuning and New Features in Oracle 19c
SQL Performance Tuning and New Features in Oracle 19cRachelBarker26
 
Presentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12cPresentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12cRonald Francisco Vargas Quesada
 
Explaining the Postgres Query Optimizer (Bruce Momjian)
Explaining the Postgres Query Optimizer (Bruce Momjian)Explaining the Postgres Query Optimizer (Bruce Momjian)
Explaining the Postgres Query Optimizer (Bruce Momjian)Ontico
 
Explain the explain_plan
Explain the explain_planExplain the explain_plan
Explain the explain_planMaria Colgan
 
Peeking into the Black Hole Called PL/PGSQL - the New PL Profiler / Jan Wieck...
Peeking into the Black Hole Called PL/PGSQL - the New PL Profiler / Jan Wieck...Peeking into the Black Hole Called PL/PGSQL - the New PL Profiler / Jan Wieck...
Peeking into the Black Hole Called PL/PGSQL - the New PL Profiler / Jan Wieck...Ontico
 
Cost-Based Optimizer in Apache Spark 2.2
Cost-Based Optimizer in Apache Spark 2.2 Cost-Based Optimizer in Apache Spark 2.2
Cost-Based Optimizer in Apache Spark 2.2 Databricks
 
Cost-Based Optimizer in Apache Spark 2.2 Ron Hu, Sameer Agarwal, Wenchen Fan ...
Cost-Based Optimizer in Apache Spark 2.2 Ron Hu, Sameer Agarwal, Wenchen Fan ...Cost-Based Optimizer in Apache Spark 2.2 Ron Hu, Sameer Agarwal, Wenchen Fan ...
Cost-Based Optimizer in Apache Spark 2.2 Ron Hu, Sameer Agarwal, Wenchen Fan ...Databricks
 
VCE Unit 01 (1).pptx
VCE Unit 01 (1).pptxVCE Unit 01 (1).pptx
VCE Unit 01 (1).pptxskilljiolms
 
SQL Server Query Optimization, Execution and Debugging Query Performance
SQL Server Query Optimization, Execution and Debugging Query PerformanceSQL Server Query Optimization, Execution and Debugging Query Performance
SQL Server Query Optimization, Execution and Debugging Query PerformanceVinod Kumar
 

Similar to Query processing and Query Optimization (20)

Overview of query evaluation
Overview of query evaluationOverview of query evaluation
Overview of query evaluation
 
Processes in Query Optimization in (ABMS) Advanced Database Management Systems
Processes in Query Optimization in (ABMS) Advanced Database Management Systems Processes in Query Optimization in (ABMS) Advanced Database Management Systems
Processes in Query Optimization in (ABMS) Advanced Database Management Systems
 
Chapter15
Chapter15Chapter15
Chapter15
 
Implementation of query optimization for reducing run time
Implementation of query optimization for reducing run timeImplementation of query optimization for reducing run time
Implementation of query optimization for reducing run time
 
LECTURE_06_DATABASE PROCESSING & OPTIMAZATION.pptx
LECTURE_06_DATABASE PROCESSING & OPTIMAZATION.pptxLECTURE_06_DATABASE PROCESSING & OPTIMAZATION.pptx
LECTURE_06_DATABASE PROCESSING & OPTIMAZATION.pptx
 
SQL Performance Tuning and New Features in Oracle 19c
SQL Performance Tuning and New Features in Oracle 19cSQL Performance Tuning and New Features in Oracle 19c
SQL Performance Tuning and New Features in Oracle 19c
 
Presentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12cPresentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12c
 
Mc seminar
Mc seminarMc seminar
Mc seminar
 
9-Query Processing-05-06-2023.PPT
9-Query Processing-05-06-2023.PPT9-Query Processing-05-06-2023.PPT
9-Query Processing-05-06-2023.PPT
 
Oracle query optimizer
Oracle query optimizerOracle query optimizer
Oracle query optimizer
 
Explaining the Postgres Query Optimizer (Bruce Momjian)
Explaining the Postgres Query Optimizer (Bruce Momjian)Explaining the Postgres Query Optimizer (Bruce Momjian)
Explaining the Postgres Query Optimizer (Bruce Momjian)
 
JMeter Database Performace Testing - Keytorc Approach
JMeter Database Performace Testing - Keytorc ApproachJMeter Database Performace Testing - Keytorc Approach
JMeter Database Performace Testing - Keytorc Approach
 
Explain the explain_plan
Explain the explain_planExplain the explain_plan
Explain the explain_plan
 
Peeking into the Black Hole Called PL/PGSQL - the New PL Profiler / Jan Wieck...
Peeking into the Black Hole Called PL/PGSQL - the New PL Profiler / Jan Wieck...Peeking into the Black Hole Called PL/PGSQL - the New PL Profiler / Jan Wieck...
Peeking into the Black Hole Called PL/PGSQL - the New PL Profiler / Jan Wieck...
 
les07.pdf
les07.pdfles07.pdf
les07.pdf
 
Cost-Based Optimizer in Apache Spark 2.2
Cost-Based Optimizer in Apache Spark 2.2 Cost-Based Optimizer in Apache Spark 2.2
Cost-Based Optimizer in Apache Spark 2.2
 
8 query
8 query8 query
8 query
 
Cost-Based Optimizer in Apache Spark 2.2 Ron Hu, Sameer Agarwal, Wenchen Fan ...
Cost-Based Optimizer in Apache Spark 2.2 Ron Hu, Sameer Agarwal, Wenchen Fan ...Cost-Based Optimizer in Apache Spark 2.2 Ron Hu, Sameer Agarwal, Wenchen Fan ...
Cost-Based Optimizer in Apache Spark 2.2 Ron Hu, Sameer Agarwal, Wenchen Fan ...
 
VCE Unit 01 (1).pptx
VCE Unit 01 (1).pptxVCE Unit 01 (1).pptx
VCE Unit 01 (1).pptx
 
SQL Server Query Optimization, Execution and Debugging Query Performance
SQL Server Query Optimization, Execution and Debugging Query PerformanceSQL Server Query Optimization, Execution and Debugging Query Performance
SQL Server Query Optimization, Execution and Debugging Query Performance
 

Recently uploaded

Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 

Recently uploaded (20)

Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 

Query processing and Query Optimization

  • 1. QUERY PROCESSING AND QUERY OPTIMIZATION By NIRAJ GANDHA
  • 2. What is Query Processing?  It is a 3 step process that transforms a high level query (sql) into an equivalent and more efficient lower-level query (of relational algebra).
  • 3. Query Query  Query is the statement written by the user in high language using pl/sql.
  • 4. Parser & Translator Query Parser & Translator  Parser: Checks the syntax and verifies the relation.  Translator: Translates the query into an equivalent relational algebra. Example: SQL> select name from customer; RA:=∏name(customer)
  • 5. Relational Algebra Query Parser & Translator Relational Algebra  It is the query converted in algebraic form from pl/ sql by translator.  Example: SQL>SELECT ENAME FROM EMP,ASG WHERE EMP.ENO=ASG.ENO AND DUR>37; RA:1) ΠENAME(σDUR>37∧EMP.ENO=ASG.ENO(EMP × ASG)) 2) ΠENAME(EMP ENO (σDUR>37(ASG)))
  • 6. Optimizer Query Parser & Translator Relational Algebra Optimizer  It will select the query which has low cost. Example: 1) ΠENAME(σDUR>37∧EMP.ENO=ASG.ENO(EMP × ASG)) 2) ΠENAME(EMP ENO (σDUR>37(ASG))) Optimizer will select Expression2 as it avoids the expensive and large intermediate Cartesian product, and therefore typically is better.
  • 7. Comparison of two relational queries  ΠENAME(σDUR>37∧EMP.ENO=ASG.ENO (EMP × ASG))  ΠENAME(EMP ENO(σDUR>37(ASG))) EMP x ASG Temp as EMP.ENO=ASG.ENO ΠENAME ENO(σDUR>37(ASG) EMP ENO ΠENAME σDUR>37 ∧temp
  • 8. Query Parser & Translator Relational Algebra Optimizer Statistical Data Statistical Data  A Statical Data is a database used for statistical analysis purposes.  It is an OLAP(Online Analytical Processing), instead of OLTP(Online Transaction Processing) system
  • 9. Evaluation Plan Query Parser & Translator Relational Algebra Optimizer Statistical Data Evaluation Plan  Relational Algebra annotated with instructions on how to evaluate it is called an evaluation primitive.  Sequence of primitive operations that can be used to evaluate a query is a query evaluation plan.
  • 10. EVALUATION & DATA  The evaluation engine takes the evaluation plan as condition and applies it on the data. Query Parser & Translator Relational Algebra Optimizer Statistical Data Evaluation Plan Evaluation  The information on which the query has to be performed is called data.Data
  • 12. Diagram of Query Processing Query Parser & Translator Relational Algebra Optimizer Statistical Data Evaluation Plan EvaluationOutput Data
  • 13. Measures of Query Cost  The cost of query evaluation can be measured in terms of different resources, including  disk accesses  CPU time to execute a query in a distributed or parallel database system  the cost of communication.
  • 14. Materialization  In materialization approach, output of every single operation is saved in temporary relation for the subsequent use.  It starts from the lowest-level operations in the expression.  Ex: Πcustomer(σbalance<2500(account) customer) Πcustomer σbalance<2500 customer account
  • 15. Pipelining  In pipelining approach, output of every single operation is not necessary to save in temporary relation for the subsequent use.  In this the operations take place simultaneously or in background  It starts from the lowest-level operations in the expression.  Ex: Πcustomer(σbalance<2500(account) customer) Πcustomer σbalance<2500 customer account
  • 16. Query Optimization  It is the process of selecting the most efficient query- evaluation plan from among the many strategies usually possible for processing a given query, especially if the query is complex.
  • 17. Example of Optimization  ∏customer(σbranch_city=”Brooklyn”(branch (account depositor))) ∏customer σbranch_city=”Brooklyn” branch account depositor  ∏customer((σbranch_city=”Brooklyn”(branc h)) (account depositor)) ∏customer σbranch_city=”Brooklyn” branch account depositor