SlideShare a Scribd company logo
Advance Database Management Systems : 40
Heuristics in Query Optimization
Prof Neeraj Bhargava
Vaibhav Khanna
Department of Computer Science
School of Engineering and Systems Sciences
Maharshi Dayanand Saraswati University Ajmer
Slide 15- 2
7. Using Heuristics in Query Optimization(1)
• Process for heuristics optimization
1. The parser of a high-level query generates an initial internal
representation;
2. Apply heuristics rules to optimize the internal representation.
3. A query execution plan is generated to execute groups of
operations based on the access paths available on the files
involved in the query.
• The main heuristic is to apply first the operations that reduce
the size of intermediate results.
– E.g., Apply SELECT and PROJECT operations before applying
the JOIN or other binary operations.
Slide 15- 3
Using Heuristics in Query Optimization (2)
• Query tree:
– A tree data structure that corresponds to a relational algebra
expression. It represents the input relations of the query as leaf
nodes of the tree, and represents the relational algebra
operations as internal nodes.
• An execution of the query tree consists of executing an
internal node operation whenever its operands are available
and then replacing that internal node by the relation that
results from executing the operation.
• Query graph:
– A graph data structure that corresponds to a relational calculus
expression. It does not indicate an order on which operations to
perform first. There is only a single graph corresponding to each
query.
Slide 15- 4
Using Heuristics in Query Optimization (3)
• Example:
– For every project located in ‘Stafford’, retrieve the project number, the
controlling department number and the department manager’s last
name, address and birthdate.
• Relation algebra:
PNUMBER, DNUM, LNAME, ADDRESS, BDATE (((PLOCATION=‘STAFFORD’(PROJECT))
DNUM=DNUMBER (DEPARTMENT)) MGRSSN=SSN (EMPLOYEE))
• SQL query:
Q2: SELECT P.NUMBER,P.DNUM,E.LNAME,
E.ADDRESS, E.BDATE
FROM PROJECT AS P,DEPARTMENT AS D,
EMPLOYEE AS E
WHERE P.DNUM=D.DNUMBER AND
D.MGRSSN=E.SSN AND
P.PLOCATION=‘STAFFORD’;
Slide 15- 5
Using Heuristics in Query Optimization (4)
Slide 15- 6
Using Heuristics in Query Optimization (5)
Slide 15- 7
Using Heuristics in Query Optimization (6)
• Heuristic Optimization of Query Trees:
– The same query could correspond to many different relational
algebra expressions — and hence many different query trees.
– The task of heuristic optimization of query trees is to find a final
query tree that is efficient to execute.
• Example:
Q: SELECT LNAME
FROM EMPLOYEE, WORKS_ON, PROJECT
WHERE PNAME = ‘AQUARIUS’ AND
PNMUBER=PNO AND ESSN=SSN
AND BDATE > ‘1957-12-31’;
Slide 15- 8
Using Heuristics in Query Optimization (7)
Slide 15- 9
Using Heuristics in Query Optimization (8)
Slide 15- 10
Using Heuristics in Query Optimization (9)
• General Transformation Rules for Relational Algebra Operations:
1. Cascade of : A conjunctive selection condition can be broken up into a
cascade (sequence) of individual  operations:
–  c1 AND c2 AND ... AND cn(R) = c1 (c2 (...(cn(R))...) )
2. Commutativity of : The  operation is commutative:
– c1 (c2(R)) = c2 (c1(R))
3. Cascade of : In a cascade (sequence) of  operations, all but the last one
can be ignored:
– List1 (List2 (...(Listn(R))...) ) = List1(R)
4. Commuting  with : If the selection condition c involves only the
attributes A1, ..., An in the projection list, the two operations can be
commuted:
– A1, A2, ..., An (c (R)) = c (A1, A2, ..., An (R))
Slide 15- 11
Using Heuristics in Query Optimization (10)
• General Transformation Rules for Relational Algebra Operations (contd.):
5. Commutativity of ( and x ): The operation is commutative as is the x
operation:
– R C S = S C R; R x S = S x R
6. Commuting  with (or x ): If all the attributes in the selection condition c
involve only the attributes of one of the relations being joined—say, R—
the two operations can be commuted as follows:
– c ( R S ) = (c (R)) S
• Alternatively, if the selection condition c can be written as (c1 and c2),
where condition c1 involves only the attributes of R and condition c2
involves only the attributes of S, the operations commute as follows:
– c ( R S ) = (c1 (R)) (c2 (S))
Slide 15- 12
Using Heuristics in Query Optimization (11)
• General Transformation Rules for Relational Algebra
Operations (contd.):
7. Commuting  with (or x): Suppose that the projection list is
L = {A1, ..., An, B1, ..., Bm}, where A1, ..., An are attributes of R
and B1, ..., Bm are attributes of S. If the join condition c
involves only attributes in L, the two operations can be
commuted as follows:
– L ( R C S ) = (A1, ..., An (R)) C ( B1, ..., Bm (S))
• If the join condition C contains additional attributes not in L,
these must be added to the projection list, and a final 
operation is needed.
Slide 15- 13
Using Heuristics in Query Optimization (12)
• General Transformation Rules for Relational Algebra
Operations (contd.):
8. Commutativity of set operations: The set operations υ and ∩
are commutative but “–” is not.
9. Associativity of , x, υ, and ∩ : These four operations are
individually associative; that is, if q stands for any one of these
four operations (throughout the expression), we have
– ( R q S ) q T = R q ( S q T )
10. Commuting  with set operations: The  operation
commutes with υ , ∩ , and –. If q stands for any one of these
three operations, we have
– c ( R q S ) = (c (R)) q (c (S))
Slide 15- 14
Using Heuristics in Query Optimization (13)
• General Transformation Rules for Relational Algebra
Operations (contd.):
• The  operation commutes with υ.
L ( R υ S ) = (L (R)) υ (L (S))
• Converting a (, x) sequence into : If the condition c of a 
that follows a x Corresponds to a join condition, convert the
(, x) sequence into a as follows:
(C (R x S)) = (R C S)
• Other transformations
Slide 15- 15
Using Heuristics in Query Optimization (14)
• Outline of a Heuristic Algebraic Optimization Algorithm:
1. Using rule 1, break up any select operations with conjunctive conditions into a
cascade of select operations.
2. Using rules 2, 4, 6, and 10 concerning the commutativity of select with other
operations, move each select operation as far down the query tree as is permitted
by the attributes involved in the select condition.
3. Using rule 9 concerning associativity of binary operations, rearrange the leaf
nodes of the tree so that the leaf node relations with the most restrictive select
operations are executed first in the query tree representation.
4. Using Rule 12, combine a Cartesian product operation with a subsequent select
operation in the tree into a join operation.
5. Using rules 3, 4, 7, and 11 concerning the cascading of project and the commuting
of project with other operations, break down and move lists of projection
attributes down the tree as far as possible by creating new project operations as
needed.
6. Identify subtrees that represent groups of operations that can be executed by a
single algorithm.
Slide 15- 16
Using Heuristics in Query Optimization (15)
• Summary of Heuristics for Algebraic Optimization:
1. The main heuristic is to apply first the operations that reduce
the size of intermediate results.
2. Perform select operations as early as possible to reduce the
number of tuples and perform project operations as early as
possible to reduce the number of attributes. (This is done by
moving select and project operations as far down the tree as
possible.)
3. The select and join operations that are most restrictive should
be executed before other similar operations. (This is done by
reordering the leaf nodes of the tree among themselves and
adjusting the rest of the tree appropriately.)
Slide 15- 17
Using Heuristics in Query Optimization (16)
• Query Execution Plans
– An execution plan for a relational algebra query consists of a
combination of the relational algebra query tree and
information about the access methods to be used for each
relation as well as the methods to be used in computing the
relational operators stored in the tree.
– Materialized evaluation: the result of an operation is stored as
a temporary relation.
– Pipelined evaluation: as the result of an operator is produced,
it is forwarded to the next operator in sequence.
Assignment
• Explain the concept and usage of Heuristics in
Query Optimization

More Related Content

What's hot (20)

PROLOG: Introduction To Prolog
PROLOG: Introduction To PrologPROLOG: Introduction To Prolog
PROLOG: Introduction To Prolog
DataminingTools Inc
 
Xml databases
Xml databasesXml databases
Xml databases
Srinivasan R
 
Lecture 1 data structures and algorithms
Lecture 1 data structures and algorithmsLecture 1 data structures and algorithms
Lecture 1 data structures and algorithms
Aakash deep Singhal
 
File systems versus a dbms
File systems versus a dbmsFile systems versus a dbms
File systems versus a dbms
RituBhargava7
 
EER modeling
EER modelingEER modeling
EER modeling
Dabbal Singh Mahara
 
Entity Relationship Diagrams
Entity Relationship DiagramsEntity Relationship Diagrams
Entity Relationship Diagrams
sadique_ghitm
 
Tree and graph
Tree and graphTree and graph
Tree and graph
Muhaiminul Islam
 
Graph in data structure
Graph in data structureGraph in data structure
Graph in data structure
Abrish06
 
Serializability
SerializabilitySerializability
Serializability
Pyingkodi Maran
 
Query processing
Query processingQuery processing
Query processing
Dr. C.V. Suresh Babu
 
Ambiguous & Unambiguous Grammar
Ambiguous & Unambiguous GrammarAmbiguous & Unambiguous Grammar
Ambiguous & Unambiguous Grammar
MdImamHasan1
 
ER-Model-ER Diagram
ER-Model-ER DiagramER-Model-ER Diagram
ER-Model-ER Diagram
Saranya Natarajan
 
Er model ppt
Er model pptEr model ppt
Er model ppt
Pihu Goel
 
Relational Data Model Introduction
Relational Data Model IntroductionRelational Data Model Introduction
Relational Data Model Introduction
Nishant Munjal
 
Splay Tree
Splay TreeSplay Tree
Splay Tree
Dr Sandeep Kumar Poonia
 
Database Design
Database DesignDatabase Design
Database Design
learnt
 
SQL - Structured query language introduction
SQL - Structured query language introductionSQL - Structured query language introduction
SQL - Structured query language introduction
Smriti Jain
 
Transaction states and properties
Transaction states and propertiesTransaction states and properties
Transaction states and properties
Chetan Mahawar
 
Query processing-and-optimization
Query processing-and-optimizationQuery processing-and-optimization
Query processing-and-optimization
WBUTTUTORIALS
 
Information retrieval s
Information retrieval sInformation retrieval s
Information retrieval s
silambu111
 
Lecture 1 data structures and algorithms
Lecture 1 data structures and algorithmsLecture 1 data structures and algorithms
Lecture 1 data structures and algorithms
Aakash deep Singhal
 
File systems versus a dbms
File systems versus a dbmsFile systems versus a dbms
File systems versus a dbms
RituBhargava7
 
Entity Relationship Diagrams
Entity Relationship DiagramsEntity Relationship Diagrams
Entity Relationship Diagrams
sadique_ghitm
 
Graph in data structure
Graph in data structureGraph in data structure
Graph in data structure
Abrish06
 
Ambiguous & Unambiguous Grammar
Ambiguous & Unambiguous GrammarAmbiguous & Unambiguous Grammar
Ambiguous & Unambiguous Grammar
MdImamHasan1
 
Er model ppt
Er model pptEr model ppt
Er model ppt
Pihu Goel
 
Relational Data Model Introduction
Relational Data Model IntroductionRelational Data Model Introduction
Relational Data Model Introduction
Nishant Munjal
 
Database Design
Database DesignDatabase Design
Database Design
learnt
 
SQL - Structured query language introduction
SQL - Structured query language introductionSQL - Structured query language introduction
SQL - Structured query language introduction
Smriti Jain
 
Transaction states and properties
Transaction states and propertiesTransaction states and properties
Transaction states and properties
Chetan Mahawar
 
Query processing-and-optimization
Query processing-and-optimizationQuery processing-and-optimization
Query processing-and-optimization
WBUTTUTORIALS
 
Information retrieval s
Information retrieval sInformation retrieval s
Information retrieval s
silambu111
 

Similar to Adbms 40 heuristics in query optimization (20)

Query processing and Optimization in Database
Query processing and Optimization in DatabaseQuery processing and Optimization in Database
Query processing and Optimization in Database
Yordanos Zewge
 
Heuristic approch monika sanghani
Heuristic approch  monika sanghaniHeuristic approch  monika sanghani
Heuristic approch monika sanghani
Monika Sanghani
 
Query optimization
Query optimizationQuery optimization
Query optimization
Zunera Bukhari
 
DB LECTURE 5 QUERY PROCESSING.pptx
DB LECTURE 5 QUERY        PROCESSING.pptxDB LECTURE 5 QUERY        PROCESSING.pptx
DB LECTURE 5 QUERY PROCESSING.pptx
grahamoyigo19
 
Query optimisation
Query optimisationQuery optimisation
Query optimisation
WBUTTUTORIALS
 
LECTURE_06_DATABASE PROCESSING & OPTIMAZATION.pptx
LECTURE_06_DATABASE PROCESSING & OPTIMAZATION.pptxLECTURE_06_DATABASE PROCESSING & OPTIMAZATION.pptx
LECTURE_06_DATABASE PROCESSING & OPTIMAZATION.pptx
AthosBeatus
 
CH5_Query Processing and Optimization.pdf
CH5_Query Processing and Optimization.pdfCH5_Query Processing and Optimization.pdf
CH5_Query Processing and Optimization.pdf
amariyarana
 
Chapter 2.pdf WND FWKJFW KSD;KFLWHFB ASNK
Chapter 2.pdf WND FWKJFW KSD;KFLWHFB ASNKChapter 2.pdf WND FWKJFW KSD;KFLWHFB ASNK
Chapter 2.pdf WND FWKJFW KSD;KFLWHFB ASNK
alemunuruhak9
 
Ch-2-Query-Process.pptx advanced database
Ch-2-Query-Process.pptx advanced databaseCh-2-Query-Process.pptx advanced database
Ch-2-Query-Process.pptx advanced database
tasheebedane
 
700442110-advanced database Ch-2-Query-Process.pptx
700442110-advanced database Ch-2-Query-Process.pptx700442110-advanced database Ch-2-Query-Process.pptx
700442110-advanced database Ch-2-Query-Process.pptx
tasheebedane
 
Chapter 4 - Query Processing and Optimization.pptx
Chapter 4 - Query Processing and Optimization.pptxChapter 4 - Query Processing and Optimization.pptx
Chapter 4 - Query Processing and Optimization.pptx
ahmed518927
 
Concepts of Query Processing in ADBMS.pptx
Concepts of Query Processing in ADBMS.pptxConcepts of Query Processing in ADBMS.pptx
Concepts of Query Processing in ADBMS.pptx
AaradhyaDixit6
 
Chapter15
Chapter15Chapter15
Chapter15
gourab87
 
Query Optimization - Brandon Latronica
Query Optimization - Brandon LatronicaQuery Optimization - Brandon Latronica
Query Optimization - Brandon Latronica
"FENG "GEORGE"" YU
 
Query processing
Query processingQuery processing
Query processing
Deepak Singh
 
Query trees
Query treesQuery trees
Query trees
Shefa Idrees
 
Transaction Management, Recovery and Query Processing.pptx
Transaction Management, Recovery and Query Processing.pptxTransaction Management, Recovery and Query Processing.pptx
Transaction Management, Recovery and Query Processing.pptx
Roshni814224
 
Computer Science DBMS_Presentations_Unit-5.pptx
Computer Science DBMS_Presentations_Unit-5.pptxComputer Science DBMS_Presentations_Unit-5.pptx
Computer Science DBMS_Presentations_Unit-5.pptx
rituah
 
Query-porcessing-& Query optimization
Query-porcessing-& Query optimizationQuery-porcessing-& Query optimization
Query-porcessing-& Query optimization
Saranya Natarajan
 
2 optimization
2 optimization2 optimization
2 optimization
Mr Patrick NIYISHAKA
 
Query processing and Optimization in Database
Query processing and Optimization in DatabaseQuery processing and Optimization in Database
Query processing and Optimization in Database
Yordanos Zewge
 
Heuristic approch monika sanghani
Heuristic approch  monika sanghaniHeuristic approch  monika sanghani
Heuristic approch monika sanghani
Monika Sanghani
 
DB LECTURE 5 QUERY PROCESSING.pptx
DB LECTURE 5 QUERY        PROCESSING.pptxDB LECTURE 5 QUERY        PROCESSING.pptx
DB LECTURE 5 QUERY PROCESSING.pptx
grahamoyigo19
 
LECTURE_06_DATABASE PROCESSING & OPTIMAZATION.pptx
LECTURE_06_DATABASE PROCESSING & OPTIMAZATION.pptxLECTURE_06_DATABASE PROCESSING & OPTIMAZATION.pptx
LECTURE_06_DATABASE PROCESSING & OPTIMAZATION.pptx
AthosBeatus
 
CH5_Query Processing and Optimization.pdf
CH5_Query Processing and Optimization.pdfCH5_Query Processing and Optimization.pdf
CH5_Query Processing and Optimization.pdf
amariyarana
 
Chapter 2.pdf WND FWKJFW KSD;KFLWHFB ASNK
Chapter 2.pdf WND FWKJFW KSD;KFLWHFB ASNKChapter 2.pdf WND FWKJFW KSD;KFLWHFB ASNK
Chapter 2.pdf WND FWKJFW KSD;KFLWHFB ASNK
alemunuruhak9
 
Ch-2-Query-Process.pptx advanced database
Ch-2-Query-Process.pptx advanced databaseCh-2-Query-Process.pptx advanced database
Ch-2-Query-Process.pptx advanced database
tasheebedane
 
700442110-advanced database Ch-2-Query-Process.pptx
700442110-advanced database Ch-2-Query-Process.pptx700442110-advanced database Ch-2-Query-Process.pptx
700442110-advanced database Ch-2-Query-Process.pptx
tasheebedane
 
Chapter 4 - Query Processing and Optimization.pptx
Chapter 4 - Query Processing and Optimization.pptxChapter 4 - Query Processing and Optimization.pptx
Chapter 4 - Query Processing and Optimization.pptx
ahmed518927
 
Concepts of Query Processing in ADBMS.pptx
Concepts of Query Processing in ADBMS.pptxConcepts of Query Processing in ADBMS.pptx
Concepts of Query Processing in ADBMS.pptx
AaradhyaDixit6
 
Query Optimization - Brandon Latronica
Query Optimization - Brandon LatronicaQuery Optimization - Brandon Latronica
Query Optimization - Brandon Latronica
"FENG "GEORGE"" YU
 
Transaction Management, Recovery and Query Processing.pptx
Transaction Management, Recovery and Query Processing.pptxTransaction Management, Recovery and Query Processing.pptx
Transaction Management, Recovery and Query Processing.pptx
Roshni814224
 
Computer Science DBMS_Presentations_Unit-5.pptx
Computer Science DBMS_Presentations_Unit-5.pptxComputer Science DBMS_Presentations_Unit-5.pptx
Computer Science DBMS_Presentations_Unit-5.pptx
rituah
 
Query-porcessing-& Query optimization
Query-porcessing-& Query optimizationQuery-porcessing-& Query optimization
Query-porcessing-& Query optimization
Saranya Natarajan
 

More from Vaibhav Khanna (20)

Information and network security 47 authentication applications
Information and network security 47 authentication applicationsInformation and network security 47 authentication applications
Information and network security 47 authentication applications
Vaibhav Khanna
 
Information and network security 46 digital signature algorithm
Information and network security 46 digital signature algorithmInformation and network security 46 digital signature algorithm
Information and network security 46 digital signature algorithm
Vaibhav Khanna
 
Information and network security 45 digital signature standard
Information and network security 45 digital signature standardInformation and network security 45 digital signature standard
Information and network security 45 digital signature standard
Vaibhav Khanna
 
Information and network security 44 direct digital signatures
Information and network security 44 direct digital signaturesInformation and network security 44 direct digital signatures
Information and network security 44 direct digital signatures
Vaibhav Khanna
 
Information and network security 43 digital signatures
Information and network security 43 digital signaturesInformation and network security 43 digital signatures
Information and network security 43 digital signatures
Vaibhav Khanna
 
Information and network security 42 security of message authentication code
Information and network security 42 security of message authentication codeInformation and network security 42 security of message authentication code
Information and network security 42 security of message authentication code
Vaibhav Khanna
 
Information and network security 41 message authentication code
Information and network security 41 message authentication codeInformation and network security 41 message authentication code
Information and network security 41 message authentication code
Vaibhav Khanna
 
Information and network security 40 sha3 secure hash algorithm
Information and network security 40 sha3 secure hash algorithmInformation and network security 40 sha3 secure hash algorithm
Information and network security 40 sha3 secure hash algorithm
Vaibhav Khanna
 
Information and network security 39 secure hash algorithm
Information and network security 39 secure hash algorithmInformation and network security 39 secure hash algorithm
Information and network security 39 secure hash algorithm
Vaibhav Khanna
 
Information and network security 38 birthday attacks and security of hash fun...
Information and network security 38 birthday attacks and security of hash fun...Information and network security 38 birthday attacks and security of hash fun...
Information and network security 38 birthday attacks and security of hash fun...
Vaibhav Khanna
 
Information and network security 37 hash functions and message authentication
Information and network security 37 hash functions and message authenticationInformation and network security 37 hash functions and message authentication
Information and network security 37 hash functions and message authentication
Vaibhav Khanna
 
Information and network security 35 the chinese remainder theorem
Information and network security 35 the chinese remainder theoremInformation and network security 35 the chinese remainder theorem
Information and network security 35 the chinese remainder theorem
Vaibhav Khanna
 
Information and network security 34 primality
Information and network security 34 primalityInformation and network security 34 primality
Information and network security 34 primality
Vaibhav Khanna
 
Information and network security 33 rsa algorithm
Information and network security 33 rsa algorithmInformation and network security 33 rsa algorithm
Information and network security 33 rsa algorithm
Vaibhav Khanna
 
Information and network security 32 principles of public key cryptosystems
Information and network security 32 principles of public key cryptosystemsInformation and network security 32 principles of public key cryptosystems
Information and network security 32 principles of public key cryptosystems
Vaibhav Khanna
 
Information and network security 31 public key cryptography
Information and network security 31 public key cryptographyInformation and network security 31 public key cryptography
Information and network security 31 public key cryptography
Vaibhav Khanna
 
Information and network security 30 random numbers
Information and network security 30 random numbersInformation and network security 30 random numbers
Information and network security 30 random numbers
Vaibhav Khanna
 
Information and network security 29 international data encryption algorithm
Information and network security 29 international data encryption algorithmInformation and network security 29 international data encryption algorithm
Information and network security 29 international data encryption algorithm
Vaibhav Khanna
 
Information and network security 28 blowfish
Information and network security 28 blowfishInformation and network security 28 blowfish
Information and network security 28 blowfish
Vaibhav Khanna
 
Information and network security 27 triple des
Information and network security 27 triple desInformation and network security 27 triple des
Information and network security 27 triple des
Vaibhav Khanna
 
Information and network security 47 authentication applications
Information and network security 47 authentication applicationsInformation and network security 47 authentication applications
Information and network security 47 authentication applications
Vaibhav Khanna
 
Information and network security 46 digital signature algorithm
Information and network security 46 digital signature algorithmInformation and network security 46 digital signature algorithm
Information and network security 46 digital signature algorithm
Vaibhav Khanna
 
Information and network security 45 digital signature standard
Information and network security 45 digital signature standardInformation and network security 45 digital signature standard
Information and network security 45 digital signature standard
Vaibhav Khanna
 
Information and network security 44 direct digital signatures
Information and network security 44 direct digital signaturesInformation and network security 44 direct digital signatures
Information and network security 44 direct digital signatures
Vaibhav Khanna
 
Information and network security 43 digital signatures
Information and network security 43 digital signaturesInformation and network security 43 digital signatures
Information and network security 43 digital signatures
Vaibhav Khanna
 
Information and network security 42 security of message authentication code
Information and network security 42 security of message authentication codeInformation and network security 42 security of message authentication code
Information and network security 42 security of message authentication code
Vaibhav Khanna
 
Information and network security 41 message authentication code
Information and network security 41 message authentication codeInformation and network security 41 message authentication code
Information and network security 41 message authentication code
Vaibhav Khanna
 
Information and network security 40 sha3 secure hash algorithm
Information and network security 40 sha3 secure hash algorithmInformation and network security 40 sha3 secure hash algorithm
Information and network security 40 sha3 secure hash algorithm
Vaibhav Khanna
 
Information and network security 39 secure hash algorithm
Information and network security 39 secure hash algorithmInformation and network security 39 secure hash algorithm
Information and network security 39 secure hash algorithm
Vaibhav Khanna
 
Information and network security 38 birthday attacks and security of hash fun...
Information and network security 38 birthday attacks and security of hash fun...Information and network security 38 birthday attacks and security of hash fun...
Information and network security 38 birthday attacks and security of hash fun...
Vaibhav Khanna
 
Information and network security 37 hash functions and message authentication
Information and network security 37 hash functions and message authenticationInformation and network security 37 hash functions and message authentication
Information and network security 37 hash functions and message authentication
Vaibhav Khanna
 
Information and network security 35 the chinese remainder theorem
Information and network security 35 the chinese remainder theoremInformation and network security 35 the chinese remainder theorem
Information and network security 35 the chinese remainder theorem
Vaibhav Khanna
 
Information and network security 34 primality
Information and network security 34 primalityInformation and network security 34 primality
Information and network security 34 primality
Vaibhav Khanna
 
Information and network security 33 rsa algorithm
Information and network security 33 rsa algorithmInformation and network security 33 rsa algorithm
Information and network security 33 rsa algorithm
Vaibhav Khanna
 
Information and network security 32 principles of public key cryptosystems
Information and network security 32 principles of public key cryptosystemsInformation and network security 32 principles of public key cryptosystems
Information and network security 32 principles of public key cryptosystems
Vaibhav Khanna
 
Information and network security 31 public key cryptography
Information and network security 31 public key cryptographyInformation and network security 31 public key cryptography
Information and network security 31 public key cryptography
Vaibhav Khanna
 
Information and network security 30 random numbers
Information and network security 30 random numbersInformation and network security 30 random numbers
Information and network security 30 random numbers
Vaibhav Khanna
 
Information and network security 29 international data encryption algorithm
Information and network security 29 international data encryption algorithmInformation and network security 29 international data encryption algorithm
Information and network security 29 international data encryption algorithm
Vaibhav Khanna
 
Information and network security 28 blowfish
Information and network security 28 blowfishInformation and network security 28 blowfish
Information and network security 28 blowfish
Vaibhav Khanna
 
Information and network security 27 triple des
Information and network security 27 triple desInformation and network security 27 triple des
Information and network security 27 triple des
Vaibhav Khanna
 

Recently uploaded (20)

IObit Uninstaller Pro Crack {2025} Download Free
IObit Uninstaller Pro Crack {2025} Download FreeIObit Uninstaller Pro Crack {2025} Download Free
IObit Uninstaller Pro Crack {2025} Download Free
Iobit Uninstaller Pro Crack
 
Advanced Cyber Security and Digital Forensics.pptx
Advanced Cyber Security and Digital Forensics.pptxAdvanced Cyber Security and Digital Forensics.pptx
Advanced Cyber Security and Digital Forensics.pptx
Muhammad54342
 
How OnePlan & Microsoft 365 Ensure Strategic Alignment with AI-Powered Portfo...
How OnePlan & Microsoft 365 Ensure Strategic Alignment with AI-Powered Portfo...How OnePlan & Microsoft 365 Ensure Strategic Alignment with AI-Powered Portfo...
How OnePlan & Microsoft 365 Ensure Strategic Alignment with AI-Powered Portfo...
OnePlan Solutions
 
Progecad 2025 Professional Cracked [Latest]
Progecad 2025 Professional Cracked [Latest]Progecad 2025 Professional Cracked [Latest]
Progecad 2025 Professional Cracked [Latest]
Luisa Weist
 
Admin, Product & Beyond with FilamentPHP.pptx
Admin, Product & Beyond with FilamentPHP.pptxAdmin, Product & Beyond with FilamentPHP.pptx
Admin, Product & Beyond with FilamentPHP.pptx
eastonmeth
 
Chapter Five - Packages.ppt JAVA SCRIPT PROGRAMMING AND
Chapter Five - Packages.ppt JAVA  SCRIPT PROGRAMMING ANDChapter Five - Packages.ppt JAVA  SCRIPT PROGRAMMING AND
Chapter Five - Packages.ppt JAVA SCRIPT PROGRAMMING AND
Jifarnecho
 
Linux Improvements in Memory Corruption Based Protections
Linux Improvements in Memory Corruption Based ProtectionsLinux Improvements in Memory Corruption Based Protections
Linux Improvements in Memory Corruption Based Protections
Vlatko Kosturjak
 
TUG Brazil - VizQL Data Service - Nik Dutra.pdf
TUG Brazil - VizQL Data Service - Nik Dutra.pdfTUG Brazil - VizQL Data Service - Nik Dutra.pdf
TUG Brazil - VizQL Data Service - Nik Dutra.pdf
Ligia Galvão
 
OpenMetadata Community Meeting - 21st May 2025
OpenMetadata Community Meeting - 21st May 2025OpenMetadata Community Meeting - 21st May 2025
OpenMetadata Community Meeting - 21st May 2025
OpenMetadata
 
Custom Rummy Game Development
Custom     Rummy     Game    DevelopmentCustom     Rummy     Game    Development
Custom Rummy Game Development
Nova Carter
 
SamFw Tool v4.9 Samsung Frp Tool Free Download
SamFw Tool v4.9 Samsung Frp Tool Free DownloadSamFw Tool v4.9 Samsung Frp Tool Free Download
SamFw Tool v4.9 Samsung Frp Tool Free Download
Iobit Uninstaller Pro Crack
 
Field service report Luzon.pptxxxxxxxxxxxxxxxx
Field service report Luzon.pptxxxxxxxxxxxxxxxxField service report Luzon.pptxxxxxxxxxxxxxxxx
Field service report Luzon.pptxxxxxxxxxxxxxxxx
kashinathgpsgc
 
CFCamp2025 - Keynote Day 1 led by Luis Majano.pdf
CFCamp2025 - Keynote Day 1 led by Luis Majano.pdfCFCamp2025 - Keynote Day 1 led by Luis Majano.pdf
CFCamp2025 - Keynote Day 1 led by Luis Majano.pdf
Ortus Solutions, Corp
 
Getting Started with BoxLang - CFCamp 2025.pdf
Getting Started with BoxLang - CFCamp 2025.pdfGetting Started with BoxLang - CFCamp 2025.pdf
Getting Started with BoxLang - CFCamp 2025.pdf
Ortus Solutions, Corp
 
15 Years of Insights from a TDD Practitioner (NDC Oslo)
15 Years of Insights from a TDD Practitioner (NDC Oslo)15 Years of Insights from a TDD Practitioner (NDC Oslo)
15 Years of Insights from a TDD Practitioner (NDC Oslo)
Dennis Doomen
 
Grand Theft Auto 6 PC Game Cracked Full Setup Download
Grand Theft Auto 6 PC Game Cracked Full Setup DownloadGrand Theft Auto 6 PC Game Cracked Full Setup Download
Grand Theft Auto 6 PC Game Cracked Full Setup Download
Iobit Uninstaller Pro Crack
 
Professional Consulting Resume of AL Davis
Professional Consulting Resume of AL DavisProfessional Consulting Resume of AL Davis
Professional Consulting Resume of AL Davis
ald303873
 
IBM-App-Connect-Overview-IBM-App-Connect-Overview.pdf
IBM-App-Connect-Overview-IBM-App-Connect-Overview.pdfIBM-App-Connect-Overview-IBM-App-Connect-Overview.pdf
IBM-App-Connect-Overview-IBM-App-Connect-Overview.pdf
JabbarAbdallah
 
Why Exceptions are just sophisticated GoTos ... and How to Move Beyond
Why Exceptions are just sophisticated GoTos ... and How to Move BeyondWhy Exceptions are just sophisticated GoTos ... and How to Move Beyond
Why Exceptions are just sophisticated GoTos ... and How to Move Beyond
Florian Wilhelm
 
Nasdanika Overview - Mission, Vision, Differentiators & Capabilities
Nasdanika Overview - Mission, Vision, Differentiators & CapabilitiesNasdanika Overview - Mission, Vision, Differentiators & Capabilities
Nasdanika Overview - Mission, Vision, Differentiators & Capabilities
Pavel Vlasov
 
IObit Uninstaller Pro Crack {2025} Download Free
IObit Uninstaller Pro Crack {2025} Download FreeIObit Uninstaller Pro Crack {2025} Download Free
IObit Uninstaller Pro Crack {2025} Download Free
Iobit Uninstaller Pro Crack
 
Advanced Cyber Security and Digital Forensics.pptx
Advanced Cyber Security and Digital Forensics.pptxAdvanced Cyber Security and Digital Forensics.pptx
Advanced Cyber Security and Digital Forensics.pptx
Muhammad54342
 
How OnePlan & Microsoft 365 Ensure Strategic Alignment with AI-Powered Portfo...
How OnePlan & Microsoft 365 Ensure Strategic Alignment with AI-Powered Portfo...How OnePlan & Microsoft 365 Ensure Strategic Alignment with AI-Powered Portfo...
How OnePlan & Microsoft 365 Ensure Strategic Alignment with AI-Powered Portfo...
OnePlan Solutions
 
Progecad 2025 Professional Cracked [Latest]
Progecad 2025 Professional Cracked [Latest]Progecad 2025 Professional Cracked [Latest]
Progecad 2025 Professional Cracked [Latest]
Luisa Weist
 
Admin, Product & Beyond with FilamentPHP.pptx
Admin, Product & Beyond with FilamentPHP.pptxAdmin, Product & Beyond with FilamentPHP.pptx
Admin, Product & Beyond with FilamentPHP.pptx
eastonmeth
 
Chapter Five - Packages.ppt JAVA SCRIPT PROGRAMMING AND
Chapter Five - Packages.ppt JAVA  SCRIPT PROGRAMMING ANDChapter Five - Packages.ppt JAVA  SCRIPT PROGRAMMING AND
Chapter Five - Packages.ppt JAVA SCRIPT PROGRAMMING AND
Jifarnecho
 
Linux Improvements in Memory Corruption Based Protections
Linux Improvements in Memory Corruption Based ProtectionsLinux Improvements in Memory Corruption Based Protections
Linux Improvements in Memory Corruption Based Protections
Vlatko Kosturjak
 
TUG Brazil - VizQL Data Service - Nik Dutra.pdf
TUG Brazil - VizQL Data Service - Nik Dutra.pdfTUG Brazil - VizQL Data Service - Nik Dutra.pdf
TUG Brazil - VizQL Data Service - Nik Dutra.pdf
Ligia Galvão
 
OpenMetadata Community Meeting - 21st May 2025
OpenMetadata Community Meeting - 21st May 2025OpenMetadata Community Meeting - 21st May 2025
OpenMetadata Community Meeting - 21st May 2025
OpenMetadata
 
Custom Rummy Game Development
Custom     Rummy     Game    DevelopmentCustom     Rummy     Game    Development
Custom Rummy Game Development
Nova Carter
 
Field service report Luzon.pptxxxxxxxxxxxxxxxx
Field service report Luzon.pptxxxxxxxxxxxxxxxxField service report Luzon.pptxxxxxxxxxxxxxxxx
Field service report Luzon.pptxxxxxxxxxxxxxxxx
kashinathgpsgc
 
CFCamp2025 - Keynote Day 1 led by Luis Majano.pdf
CFCamp2025 - Keynote Day 1 led by Luis Majano.pdfCFCamp2025 - Keynote Day 1 led by Luis Majano.pdf
CFCamp2025 - Keynote Day 1 led by Luis Majano.pdf
Ortus Solutions, Corp
 
Getting Started with BoxLang - CFCamp 2025.pdf
Getting Started with BoxLang - CFCamp 2025.pdfGetting Started with BoxLang - CFCamp 2025.pdf
Getting Started with BoxLang - CFCamp 2025.pdf
Ortus Solutions, Corp
 
15 Years of Insights from a TDD Practitioner (NDC Oslo)
15 Years of Insights from a TDD Practitioner (NDC Oslo)15 Years of Insights from a TDD Practitioner (NDC Oslo)
15 Years of Insights from a TDD Practitioner (NDC Oslo)
Dennis Doomen
 
Grand Theft Auto 6 PC Game Cracked Full Setup Download
Grand Theft Auto 6 PC Game Cracked Full Setup DownloadGrand Theft Auto 6 PC Game Cracked Full Setup Download
Grand Theft Auto 6 PC Game Cracked Full Setup Download
Iobit Uninstaller Pro Crack
 
Professional Consulting Resume of AL Davis
Professional Consulting Resume of AL DavisProfessional Consulting Resume of AL Davis
Professional Consulting Resume of AL Davis
ald303873
 
IBM-App-Connect-Overview-IBM-App-Connect-Overview.pdf
IBM-App-Connect-Overview-IBM-App-Connect-Overview.pdfIBM-App-Connect-Overview-IBM-App-Connect-Overview.pdf
IBM-App-Connect-Overview-IBM-App-Connect-Overview.pdf
JabbarAbdallah
 
Why Exceptions are just sophisticated GoTos ... and How to Move Beyond
Why Exceptions are just sophisticated GoTos ... and How to Move BeyondWhy Exceptions are just sophisticated GoTos ... and How to Move Beyond
Why Exceptions are just sophisticated GoTos ... and How to Move Beyond
Florian Wilhelm
 
Nasdanika Overview - Mission, Vision, Differentiators & Capabilities
Nasdanika Overview - Mission, Vision, Differentiators & CapabilitiesNasdanika Overview - Mission, Vision, Differentiators & Capabilities
Nasdanika Overview - Mission, Vision, Differentiators & Capabilities
Pavel Vlasov
 

Adbms 40 heuristics in query optimization

  • 1. Advance Database Management Systems : 40 Heuristics in Query Optimization Prof Neeraj Bhargava Vaibhav Khanna Department of Computer Science School of Engineering and Systems Sciences Maharshi Dayanand Saraswati University Ajmer
  • 2. Slide 15- 2 7. Using Heuristics in Query Optimization(1) • Process for heuristics optimization 1. The parser of a high-level query generates an initial internal representation; 2. Apply heuristics rules to optimize the internal representation. 3. A query execution plan is generated to execute groups of operations based on the access paths available on the files involved in the query. • The main heuristic is to apply first the operations that reduce the size of intermediate results. – E.g., Apply SELECT and PROJECT operations before applying the JOIN or other binary operations.
  • 3. Slide 15- 3 Using Heuristics in Query Optimization (2) • Query tree: – A tree data structure that corresponds to a relational algebra expression. It represents the input relations of the query as leaf nodes of the tree, and represents the relational algebra operations as internal nodes. • An execution of the query tree consists of executing an internal node operation whenever its operands are available and then replacing that internal node by the relation that results from executing the operation. • Query graph: – A graph data structure that corresponds to a relational calculus expression. It does not indicate an order on which operations to perform first. There is only a single graph corresponding to each query.
  • 4. Slide 15- 4 Using Heuristics in Query Optimization (3) • Example: – For every project located in ‘Stafford’, retrieve the project number, the controlling department number and the department manager’s last name, address and birthdate. • Relation algebra: PNUMBER, DNUM, LNAME, ADDRESS, BDATE (((PLOCATION=‘STAFFORD’(PROJECT)) DNUM=DNUMBER (DEPARTMENT)) MGRSSN=SSN (EMPLOYEE)) • SQL query: Q2: SELECT P.NUMBER,P.DNUM,E.LNAME, E.ADDRESS, E.BDATE FROM PROJECT AS P,DEPARTMENT AS D, EMPLOYEE AS E WHERE P.DNUM=D.DNUMBER AND D.MGRSSN=E.SSN AND P.PLOCATION=‘STAFFORD’;
  • 5. Slide 15- 5 Using Heuristics in Query Optimization (4)
  • 6. Slide 15- 6 Using Heuristics in Query Optimization (5)
  • 7. Slide 15- 7 Using Heuristics in Query Optimization (6) • Heuristic Optimization of Query Trees: – The same query could correspond to many different relational algebra expressions — and hence many different query trees. – The task of heuristic optimization of query trees is to find a final query tree that is efficient to execute. • Example: Q: SELECT LNAME FROM EMPLOYEE, WORKS_ON, PROJECT WHERE PNAME = ‘AQUARIUS’ AND PNMUBER=PNO AND ESSN=SSN AND BDATE > ‘1957-12-31’;
  • 8. Slide 15- 8 Using Heuristics in Query Optimization (7)
  • 9. Slide 15- 9 Using Heuristics in Query Optimization (8)
  • 10. Slide 15- 10 Using Heuristics in Query Optimization (9) • General Transformation Rules for Relational Algebra Operations: 1. Cascade of : A conjunctive selection condition can be broken up into a cascade (sequence) of individual  operations: –  c1 AND c2 AND ... AND cn(R) = c1 (c2 (...(cn(R))...) ) 2. Commutativity of : The  operation is commutative: – c1 (c2(R)) = c2 (c1(R)) 3. Cascade of : In a cascade (sequence) of  operations, all but the last one can be ignored: – List1 (List2 (...(Listn(R))...) ) = List1(R) 4. Commuting  with : If the selection condition c involves only the attributes A1, ..., An in the projection list, the two operations can be commuted: – A1, A2, ..., An (c (R)) = c (A1, A2, ..., An (R))
  • 11. Slide 15- 11 Using Heuristics in Query Optimization (10) • General Transformation Rules for Relational Algebra Operations (contd.): 5. Commutativity of ( and x ): The operation is commutative as is the x operation: – R C S = S C R; R x S = S x R 6. Commuting  with (or x ): If all the attributes in the selection condition c involve only the attributes of one of the relations being joined—say, R— the two operations can be commuted as follows: – c ( R S ) = (c (R)) S • Alternatively, if the selection condition c can be written as (c1 and c2), where condition c1 involves only the attributes of R and condition c2 involves only the attributes of S, the operations commute as follows: – c ( R S ) = (c1 (R)) (c2 (S))
  • 12. Slide 15- 12 Using Heuristics in Query Optimization (11) • General Transformation Rules for Relational Algebra Operations (contd.): 7. Commuting  with (or x): Suppose that the projection list is L = {A1, ..., An, B1, ..., Bm}, where A1, ..., An are attributes of R and B1, ..., Bm are attributes of S. If the join condition c involves only attributes in L, the two operations can be commuted as follows: – L ( R C S ) = (A1, ..., An (R)) C ( B1, ..., Bm (S)) • If the join condition C contains additional attributes not in L, these must be added to the projection list, and a final  operation is needed.
  • 13. Slide 15- 13 Using Heuristics in Query Optimization (12) • General Transformation Rules for Relational Algebra Operations (contd.): 8. Commutativity of set operations: The set operations υ and ∩ are commutative but “–” is not. 9. Associativity of , x, υ, and ∩ : These four operations are individually associative; that is, if q stands for any one of these four operations (throughout the expression), we have – ( R q S ) q T = R q ( S q T ) 10. Commuting  with set operations: The  operation commutes with υ , ∩ , and –. If q stands for any one of these three operations, we have – c ( R q S ) = (c (R)) q (c (S))
  • 14. Slide 15- 14 Using Heuristics in Query Optimization (13) • General Transformation Rules for Relational Algebra Operations (contd.): • The  operation commutes with υ. L ( R υ S ) = (L (R)) υ (L (S)) • Converting a (, x) sequence into : If the condition c of a  that follows a x Corresponds to a join condition, convert the (, x) sequence into a as follows: (C (R x S)) = (R C S) • Other transformations
  • 15. Slide 15- 15 Using Heuristics in Query Optimization (14) • Outline of a Heuristic Algebraic Optimization Algorithm: 1. Using rule 1, break up any select operations with conjunctive conditions into a cascade of select operations. 2. Using rules 2, 4, 6, and 10 concerning the commutativity of select with other operations, move each select operation as far down the query tree as is permitted by the attributes involved in the select condition. 3. Using rule 9 concerning associativity of binary operations, rearrange the leaf nodes of the tree so that the leaf node relations with the most restrictive select operations are executed first in the query tree representation. 4. Using Rule 12, combine a Cartesian product operation with a subsequent select operation in the tree into a join operation. 5. Using rules 3, 4, 7, and 11 concerning the cascading of project and the commuting of project with other operations, break down and move lists of projection attributes down the tree as far as possible by creating new project operations as needed. 6. Identify subtrees that represent groups of operations that can be executed by a single algorithm.
  • 16. Slide 15- 16 Using Heuristics in Query Optimization (15) • Summary of Heuristics for Algebraic Optimization: 1. The main heuristic is to apply first the operations that reduce the size of intermediate results. 2. Perform select operations as early as possible to reduce the number of tuples and perform project operations as early as possible to reduce the number of attributes. (This is done by moving select and project operations as far down the tree as possible.) 3. The select and join operations that are most restrictive should be executed before other similar operations. (This is done by reordering the leaf nodes of the tree among themselves and adjusting the rest of the tree appropriately.)
  • 17. Slide 15- 17 Using Heuristics in Query Optimization (16) • Query Execution Plans – An execution plan for a relational algebra query consists of a combination of the relational algebra query tree and information about the access methods to be used for each relation as well as the methods to be used in computing the relational operators stored in the tree. – Materialized evaluation: the result of an operation is stored as a temporary relation. – Pipelined evaluation: as the result of an operator is produced, it is forwarded to the next operator in sequence.
  • 18. Assignment • Explain the concept and usage of Heuristics in Query Optimization
  翻译: