尊敬的 微信汇率:1円 ≈ 0.046215 元 支付宝汇率:1円 ≈ 0.046306元 [退出登录]
SlideShare a Scribd company logo
Different algorithm to implement joins are
Nested-loop join
Block nested-loop join
Indexed nested-loop join
Merge join
Hash join
Choice based on cost estimate
Example
Number of records of customer 10,000 depositor 5000
Number of blocks of customer 40 depositor 100
1.Nested-loop join
A nested loop join is a naive algorithm that
joins two sets by using two nested loops. Join
operations are important to database management.
Algorithm:
Two relations and are joined as follows:
For each tuple r in R do
For each tuple s in S do
If r and s satisfy the join condition
Then output the tuple <r,s>
This algorithm will involve nr*bs+ br block transfers and
nr+br seeks, where br and bs are number of blocks in
relations r and s respectively, and nr is the number of tuples
in relation r.
The algorithm runs in I/Os, where and is the number of
tuples contained in and respectively. Can easily be
generalized to join any number of relations.
The block nested loop join algorithm is a generalization of
the simple nested loops algorithm that takes advantage of
additional memory to reduce the number of times that the
relation is scanned.
2.Block nested-loop join
Algorithm:
for each block BR of R do begin
for each block BS of S do begin
for each tuple tR in BR do
for each tuple tS in BS do
check whether pair (tR; tS)
satises join condition
if they do, add tR tS to the result
end end end end
Also requires no indexes and can be used with any kind of join
condition.
Worst case: db buffer can only hold one block of each relation
=) br*bs+br disk accesses.
Best case: both relations t into db buffer
=) br+bs disk accesses.
If smaller relation completely ts into db buffer, use that as inner
relation. Reduces the cost estimate to BR + BS disk accesses.
3. Index Nested-Loop Join
 If an index is available on the inner loop's join attribute and join is
an equi-join or natural join, more efficient index lookups can
replace scans.
 It is even possible (reasonable) to construct index just to compute
a join.
 For each tuple tr in the outer relation R, use the index to lookup
tuples in S that satisfy join condition with tr
 Worst case: db buffer has space for only one page of R and one
page of the index associated with S:
 br disk accesses to read R, and for each tuple in R, perform
index lookup on S.
 Cost of the join: br+nr*c, where c is the cost of a single
selection on S using the join condition.
 If indexes are available on both R and S, use the one with the
fewer tuples as the outer relation.
4.Merge Join
Basic idea: first sort both relations on join attribute
(if not already sorted this way)
 Join steps are similar to the merge stage in the
external
sort-merge algorithm (discussed later)
 Every pair with same value on join attribute must
be matched.
values of join attributes
Relation R Relation S
1
2
2
3
4
5
1
2
3
3
5
If no repeated join attribute values, each tuple needs to be
read only once. As a result, each block is read only once.
Thus, the number of block accesses is BR + BS (plus the cost
of sorting, if relations are unsorted).
Worst case: all join attribute values are the same. Then the
number of block accesses is br*bs+br
If one relation is sorted and the other has a secondary B+-
tree index on the join attribute, a hybrid merge-join is
possible.
The sorted relation is merged with the leaf node entries of
the B+-tree. The result is sorted on the addresses (rids) of the
unsorted relation's tuples, and then the addresses can be
replaced by the actual tuples efficiently.
5.Hash-Join
only applicable in case of equi-join or natural join
A hash function is used to partition tuples of both
relations into sets that have the same hash value on
the join attribute
Partitioning Phase: 2 * Br+Bs block accesses
Matching Phase: Br+Bs block accesses
(under the assumption that one partition of each
relation ts into the database buffer)
OTHER OPERATIONS
Duplicate Elimination
Sorting: remove all but one copy of tuples
having identical value(s) on projection
attribute(s)
Hashing: partition relation using hash function
on projection attribute(s); then read partitions
into buffer and create in-memory hash index;
tuple is only inserted into index if not already
present
Set Operations:
Sorting or hashing
Hashing: Partition both relations using the same
hash function; use in-memory index for partitions Ri
R U S: if tuple in Ri or in Si, add tuple to result
∩: if tuple in Ri and in Si, . . .
- : if tuple in Ri and not in Si, . . .
Grouping and aggregation:
Compute groups via sorting or hashing.
Hashing: while groups (partitions) are built,
compute partial aggregate values (for group
attribute A, V(A,R) tuples to store values)
Evaluation of Expressions
Alternatives for evaluating an entire expression tree
are
Materialization: generate results of an expression
whose inputs are relations or are already computed,
materialize it on disk. repeat
Pipelining: pass on tuples to parent operations even
as an operation is being executed.
Evaluation of Expressions
Strategy 1: materialization. Evaluate one operation
at a time, starting at the lowest level. Use
intermediate results materialized in temporary
relations to evaluate next level operation(s).
Example: in figure below, compute and store.
σ balance<2500(account) the store its join with customer and finally
compute the projections on customer name.
Лcustomer name
∞
Лbalance<2500 customer
account
 Materialized evaluation is always applicable.
Cost of writing results to disk and editing them
back can be quite high.
overall cost = sum of cost of individual
operations + cost of writing intermediate results to
disk.
Double Buffering: use two O/P buffer for each
operation, when one is full write it to disk while
the other is getting filled, reduced execution time.
Strategy 2: pipelining. evaluate several
operations simultaneously, and pass the result
(tuple- or block-wise)on to the next operation.
In the example above, once a tuple from
OFFERS satisfying selection condition has been
found, pass it on to the join. Similarly, don't store
result of (final) join, but pass tuples directly to
projection.
Much cheaper than materialization, because
temporary relations are not generated and stored
on disk.
Pipelining is not always possible, e.g., for all
operations that include sorting (blocking
operation).
Pipelining can be executed in either demand
driven or producer driven fashion.
DATABASE TUNINIG
Tuning:
The process of continuing to revise/adjust the physical
database design by monitoring resource utilization as well as
internal DBMS processing to reveal bottlenecks such as
contention for the same data or devices.
Goal:
To make application run faster
To lower the response time of queries/transactions
To improve the overall throughput of transactions
Tuning Indexes
Reasons to tuning indexes
Certain queries may take too long to run for lack of
an index;
Certain indexes may not get utilized at all;
Certain indexes may be causing excessive overhead
because the index is on an attribute that undergoes
frequent changes
Options to tuning indexes
Drop or/and build new indexes
Change a non-clustered index to a clustered index
(and vice versa)
Rebuilding the index
Tuning the Database Design
Dynamically changed processing requirements
need to be addressed by making changes to the
conceptual schema if necessary and to reflect
those changes into the logical schema and
physical design.
Tuning Queries
Indications for tuning queries
A query issues too many disk accesses
The query plan shows that relevant indexes
are not being used.

More Related Content

What's hot

Relational algebra in dbms
Relational algebra in dbmsRelational algebra in dbms
Relational algebra in dbms
Vignesh Saravanan
 
Introduction to data structure ppt
Introduction to data structure pptIntroduction to data structure ppt
Introduction to data structure ppt
NalinNishant3
 
Graphs In Data Structure
Graphs In Data StructureGraphs In Data Structure
Graphs In Data Structure
Anuj Modi
 
Decomposition using Functional Dependency
Decomposition using Functional DependencyDecomposition using Functional Dependency
Decomposition using Functional Dependency
Raj Naik
 
Database architecture
Database architectureDatabase architecture
Database architecture
VENNILAV6
 
1.1. the central concepts of automata theory
1.1. the central concepts of automata theory1.1. the central concepts of automata theory
1.1. the central concepts of automata theory
Sampath Kumar S
 
Symbol table in compiler Design
Symbol table in compiler DesignSymbol table in compiler Design
Symbol table in compiler Design
Kuppusamy P
 
Syntax directed translation
Syntax directed translationSyntax directed translation
Syntax directed translation
Akshaya Arunan
 
14. Query Optimization in DBMS
14. Query Optimization in DBMS14. Query Optimization in DBMS
14. Query Optimization in DBMS
koolkampus
 
Red black tree
Red black treeRed black tree
Red black tree
Dr Sandeep Kumar Poonia
 
Graph in data structure
Graph in data structureGraph in data structure
Graph in data structure
Abrish06
 
9. Object Relational Databases in DBMS
9. Object Relational Databases in DBMS9. Object Relational Databases in DBMS
9. Object Relational Databases in DBMS
koolkampus
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity Constraints
madhav bansal
 
DBMS 3 | ER Diagram to Relational Schema
DBMS 3 | ER Diagram to Relational SchemaDBMS 3 | ER Diagram to Relational Schema
DBMS 3 | ER Diagram to Relational Schema
Mohammad Imam Hossain
 
6. Integrity and Security in DBMS
6. Integrity and Security in DBMS6. Integrity and Security in DBMS
6. Integrity and Security in DBMS
koolkampus
 
16. Concurrency Control in DBMS
16. Concurrency Control in DBMS16. Concurrency Control in DBMS
16. Concurrency Control in DBMS
koolkampus
 
Nested Queries Lecture
Nested Queries LectureNested Queries Lecture
Nested Queries Lecture
Felipe Costa
 
Symbol Table
Symbol TableSymbol Table
Symbol Table
Akhil Kaushik
 
B tree
B treeB tree
B tree
Rajendran
 
Degree of relationship set
Degree of relationship setDegree of relationship set
Degree of relationship set
Megha Sharma
 

What's hot (20)

Relational algebra in dbms
Relational algebra in dbmsRelational algebra in dbms
Relational algebra in dbms
 
Introduction to data structure ppt
Introduction to data structure pptIntroduction to data structure ppt
Introduction to data structure ppt
 
Graphs In Data Structure
Graphs In Data StructureGraphs In Data Structure
Graphs In Data Structure
 
Decomposition using Functional Dependency
Decomposition using Functional DependencyDecomposition using Functional Dependency
Decomposition using Functional Dependency
 
Database architecture
Database architectureDatabase architecture
Database architecture
 
1.1. the central concepts of automata theory
1.1. the central concepts of automata theory1.1. the central concepts of automata theory
1.1. the central concepts of automata theory
 
Symbol table in compiler Design
Symbol table in compiler DesignSymbol table in compiler Design
Symbol table in compiler Design
 
Syntax directed translation
Syntax directed translationSyntax directed translation
Syntax directed translation
 
14. Query Optimization in DBMS
14. Query Optimization in DBMS14. Query Optimization in DBMS
14. Query Optimization in DBMS
 
Red black tree
Red black treeRed black tree
Red black tree
 
Graph in data structure
Graph in data structureGraph in data structure
Graph in data structure
 
9. Object Relational Databases in DBMS
9. Object Relational Databases in DBMS9. Object Relational Databases in DBMS
9. Object Relational Databases in DBMS
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity Constraints
 
DBMS 3 | ER Diagram to Relational Schema
DBMS 3 | ER Diagram to Relational SchemaDBMS 3 | ER Diagram to Relational Schema
DBMS 3 | ER Diagram to Relational Schema
 
6. Integrity and Security in DBMS
6. Integrity and Security in DBMS6. Integrity and Security in DBMS
6. Integrity and Security in DBMS
 
16. Concurrency Control in DBMS
16. Concurrency Control in DBMS16. Concurrency Control in DBMS
16. Concurrency Control in DBMS
 
Nested Queries Lecture
Nested Queries LectureNested Queries Lecture
Nested Queries Lecture
 
Symbol Table
Symbol TableSymbol Table
Symbol Table
 
B tree
B treeB tree
B tree
 
Degree of relationship set
Degree of relationship setDegree of relationship set
Degree of relationship set
 

Viewers also liked

Hash join
Hash joinHash join
Query processing and optimization
Query processing and optimizationQuery processing and optimization
Query processing and optimization
Arif A.
 
Query execution
Query executionQuery execution
Query execution
Digvijay Singh
 
Gpu Join Presentation
Gpu Join PresentationGpu Join Presentation
Gpu Join Presentation
Suman Karumuri
 
Something about oracle joins
Something about oracle joinsSomething about oracle joins
Something about oracle joins
mysqlops
 
Corba and-java
Corba and-javaCorba and-java
Corba and-java
afreen58
 
Rmi, corba and java beans
Rmi, corba and java beansRmi, corba and java beans
Rmi, corba and java beans
Raghu nath
 
Database , 8 Query Optimization
Database , 8 Query OptimizationDatabase , 8 Query Optimization
Database , 8 Query Optimization
Ali Usman
 
Oracle: Joins
Oracle: JoinsOracle: Joins
Oracle: Joins
oracle content
 
Algorithm.ppt
Algorithm.pptAlgorithm.ppt
Algorithm.ppt
Tareq Hasan
 
7. Relational Database Design in DBMS
7. Relational Database Design in DBMS7. Relational Database Design in DBMS
7. Relational Database Design in DBMS
koolkampus
 
13. Query Processing in DBMS
13. Query Processing in DBMS13. Query Processing in DBMS
13. Query Processing in DBMS
koolkampus
 
Webinar Smile et WSO2
Webinar Smile et WSO2Webinar Smile et WSO2
Webinar Smile et WSO2
Smile I.T is open
 
Ejb
Ejb Ejb
Ejb
kikoumou
 
Slideshare ppt
Slideshare pptSlideshare ppt
Slideshare ppt
Mandy Suzanne
 

Viewers also liked (15)

Hash join
Hash joinHash join
Hash join
 
Query processing and optimization
Query processing and optimizationQuery processing and optimization
Query processing and optimization
 
Query execution
Query executionQuery execution
Query execution
 
Gpu Join Presentation
Gpu Join PresentationGpu Join Presentation
Gpu Join Presentation
 
Something about oracle joins
Something about oracle joinsSomething about oracle joins
Something about oracle joins
 
Corba and-java
Corba and-javaCorba and-java
Corba and-java
 
Rmi, corba and java beans
Rmi, corba and java beansRmi, corba and java beans
Rmi, corba and java beans
 
Database , 8 Query Optimization
Database , 8 Query OptimizationDatabase , 8 Query Optimization
Database , 8 Query Optimization
 
Oracle: Joins
Oracle: JoinsOracle: Joins
Oracle: Joins
 
Algorithm.ppt
Algorithm.pptAlgorithm.ppt
Algorithm.ppt
 
7. Relational Database Design in DBMS
7. Relational Database Design in DBMS7. Relational Database Design in DBMS
7. Relational Database Design in DBMS
 
13. Query Processing in DBMS
13. Query Processing in DBMS13. Query Processing in DBMS
13. Query Processing in DBMS
 
Webinar Smile et WSO2
Webinar Smile et WSO2Webinar Smile et WSO2
Webinar Smile et WSO2
 
Ejb
Ejb Ejb
Ejb
 
Slideshare ppt
Slideshare pptSlideshare ppt
Slideshare ppt
 

Similar to Join operation

Join Operation.pptx
Join Operation.pptxJoin Operation.pptx
Join Operation.pptx
ComputerScienceDepar6
 
Query processing System
Query processing SystemQuery processing System
Lesson11 transactions
Lesson11 transactionsLesson11 transactions
Lesson11 transactions
teddy demissie
 
Query Optimization - Brandon Latronica
Query Optimization - Brandon LatronicaQuery Optimization - Brandon Latronica
Query Optimization - Brandon Latronica
"FENG "GEORGE"" YU
 
Ch13
Ch13Ch13
Query trees
Query treesQuery trees
Query trees
Shefa Idrees
 
ch13
ch13ch13
Hashing and File Structures in Data Structure.pdf
Hashing and File Structures in Data Structure.pdfHashing and File Structures in Data Structure.pdf
Hashing and File Structures in Data Structure.pdf
JaithoonBibi
 
for sbi so Ds c c++ unix rdbms sql cn os
for sbi so   Ds c c++ unix rdbms sql cn osfor sbi so   Ds c c++ unix rdbms sql cn os
for sbi so Ds c c++ unix rdbms sql cn os
alisha230390
 
Algorithms for Query Processing and Optimization of Spatial Operations
Algorithms for Query Processing and Optimization of Spatial OperationsAlgorithms for Query Processing and Optimization of Spatial Operations
Algorithms for Query Processing and Optimization of Spatial Operations
Natasha Mandal
 
Algorithm ch13.ppt
Algorithm ch13.pptAlgorithm ch13.ppt
Algorithm ch13.ppt
Dreamless2
 
Seminar - Similarity Joins in SQL (performance and semantic joins)
Seminar - Similarity Joins in SQL (performance and semantic joins)Seminar - Similarity Joins in SQL (performance and semantic joins)
Seminar - Similarity Joins in SQL (performance and semantic joins)
Eyal Trabelsi
 
Query Processing, Query Optimization and Transaction
Query Processing, Query Optimization and TransactionQuery Processing, Query Optimization and Transaction
Query Processing, Query Optimization and Transaction
Prabu U
 
Bigdata analytics
Bigdata analyticsBigdata analytics
Bigdata analytics
lakshmidkurup
 
Improved Query Performance With Variant Indexes - review presentation
Improved Query Performance With Variant Indexes - review presentationImproved Query Performance With Variant Indexes - review presentation
Improved Query Performance With Variant Indexes - review presentation
Vimukthi Wickramasinghe
 
January 2016 Meetup: Speeding up (big) data manipulation with data.table package
January 2016 Meetup: Speeding up (big) data manipulation with data.table packageJanuary 2016 Meetup: Speeding up (big) data manipulation with data.table package
January 2016 Meetup: Speeding up (big) data manipulation with data.table package
Zurich_R_User_Group
 
The D-basis Algorithm for Association Rules of High Confidence
The D-basis Algorithm for Association Rules of High ConfidenceThe D-basis Algorithm for Association Rules of High Confidence
The D-basis Algorithm for Association Rules of High Confidence
ITIIIndustries
 
Bloom Filters: An Introduction
Bloom Filters: An IntroductionBloom Filters: An Introduction
Bloom Filters: An Introduction
IRJET Journal
 
Final exam in advance dbms
Final exam in advance dbmsFinal exam in advance dbms
Final exam in advance dbms
Md. Mashiur Rahman
 
ch12.ppt
ch12.pptch12.ppt
ch12.ppt
rsingh5987
 

Similar to Join operation (20)

Join Operation.pptx
Join Operation.pptxJoin Operation.pptx
Join Operation.pptx
 
Query processing System
Query processing SystemQuery processing System
Query processing System
 
Lesson11 transactions
Lesson11 transactionsLesson11 transactions
Lesson11 transactions
 
Query Optimization - Brandon Latronica
Query Optimization - Brandon LatronicaQuery Optimization - Brandon Latronica
Query Optimization - Brandon Latronica
 
Ch13
Ch13Ch13
Ch13
 
Query trees
Query treesQuery trees
Query trees
 
ch13
ch13ch13
ch13
 
Hashing and File Structures in Data Structure.pdf
Hashing and File Structures in Data Structure.pdfHashing and File Structures in Data Structure.pdf
Hashing and File Structures in Data Structure.pdf
 
for sbi so Ds c c++ unix rdbms sql cn os
for sbi so   Ds c c++ unix rdbms sql cn osfor sbi so   Ds c c++ unix rdbms sql cn os
for sbi so Ds c c++ unix rdbms sql cn os
 
Algorithms for Query Processing and Optimization of Spatial Operations
Algorithms for Query Processing and Optimization of Spatial OperationsAlgorithms for Query Processing and Optimization of Spatial Operations
Algorithms for Query Processing and Optimization of Spatial Operations
 
Algorithm ch13.ppt
Algorithm ch13.pptAlgorithm ch13.ppt
Algorithm ch13.ppt
 
Seminar - Similarity Joins in SQL (performance and semantic joins)
Seminar - Similarity Joins in SQL (performance and semantic joins)Seminar - Similarity Joins in SQL (performance and semantic joins)
Seminar - Similarity Joins in SQL (performance and semantic joins)
 
Query Processing, Query Optimization and Transaction
Query Processing, Query Optimization and TransactionQuery Processing, Query Optimization and Transaction
Query Processing, Query Optimization and Transaction
 
Bigdata analytics
Bigdata analyticsBigdata analytics
Bigdata analytics
 
Improved Query Performance With Variant Indexes - review presentation
Improved Query Performance With Variant Indexes - review presentationImproved Query Performance With Variant Indexes - review presentation
Improved Query Performance With Variant Indexes - review presentation
 
January 2016 Meetup: Speeding up (big) data manipulation with data.table package
January 2016 Meetup: Speeding up (big) data manipulation with data.table packageJanuary 2016 Meetup: Speeding up (big) data manipulation with data.table package
January 2016 Meetup: Speeding up (big) data manipulation with data.table package
 
The D-basis Algorithm for Association Rules of High Confidence
The D-basis Algorithm for Association Rules of High ConfidenceThe D-basis Algorithm for Association Rules of High Confidence
The D-basis Algorithm for Association Rules of High Confidence
 
Bloom Filters: An Introduction
Bloom Filters: An IntroductionBloom Filters: An Introduction
Bloom Filters: An Introduction
 
Final exam in advance dbms
Final exam in advance dbmsFinal exam in advance dbms
Final exam in advance dbms
 
ch12.ppt
ch12.pptch12.ppt
ch12.ppt
 

Recently uploaded

This study Examines the Effectiveness of Talent Procurement through the Imple...
This study Examines the Effectiveness of Talent Procurement through the Imple...This study Examines the Effectiveness of Talent Procurement through the Imple...
This study Examines the Effectiveness of Talent Procurement through the Imple...
DharmaBanothu
 
Update 40 models( Solar Cell ) in SPICE PARK(JUL2024)
Update 40 models( Solar Cell ) in SPICE PARK(JUL2024)Update 40 models( Solar Cell ) in SPICE PARK(JUL2024)
Update 40 models( Solar Cell ) in SPICE PARK(JUL2024)
Tsuyoshi Horigome
 
Mahipalpur Call Girls Delhi 🔥 9711199012 ❄- Pick Your Dream Call Girls with 1...
Mahipalpur Call Girls Delhi 🔥 9711199012 ❄- Pick Your Dream Call Girls with 1...Mahipalpur Call Girls Delhi 🔥 9711199012 ❄- Pick Your Dream Call Girls with 1...
Mahipalpur Call Girls Delhi 🔥 9711199012 ❄- Pick Your Dream Call Girls with 1...
simrangupta87541
 
Call Girls Chennai +91-8824825030 Vip Call Girls Chennai
Call Girls Chennai +91-8824825030 Vip Call Girls ChennaiCall Girls Chennai +91-8824825030 Vip Call Girls Chennai
Call Girls Chennai +91-8824825030 Vip Call Girls Chennai
paraasingh12 #V08
 
Impartiality as per ISO /IEC 17025:2017 Standard
Impartiality as per ISO /IEC 17025:2017 StandardImpartiality as per ISO /IEC 17025:2017 Standard
Impartiality as per ISO /IEC 17025:2017 Standard
MuhammadJazib15
 
CSP_Study - Notes (Paul McNeill) 2017.pdf
CSP_Study - Notes (Paul McNeill) 2017.pdfCSP_Study - Notes (Paul McNeill) 2017.pdf
CSP_Study - Notes (Paul McNeill) 2017.pdf
Ismail Sultan
 
SPICE PARK JUL2024 ( 6,866 SPICE Models )
SPICE PARK JUL2024 ( 6,866 SPICE Models )SPICE PARK JUL2024 ( 6,866 SPICE Models )
SPICE PARK JUL2024 ( 6,866 SPICE Models )
Tsuyoshi Horigome
 
Asymmetrical Repulsion Magnet Motor Ratio 6-7.pdf
Asymmetrical Repulsion Magnet Motor Ratio 6-7.pdfAsymmetrical Repulsion Magnet Motor Ratio 6-7.pdf
Asymmetrical Repulsion Magnet Motor Ratio 6-7.pdf
felixwold
 
🚺ANJALI MEHTA High Profile Call Girls Ahmedabad 💯Call Us 🔝 9352988975 🔝💃Top C...
🚺ANJALI MEHTA High Profile Call Girls Ahmedabad 💯Call Us 🔝 9352988975 🔝💃Top C...🚺ANJALI MEHTA High Profile Call Girls Ahmedabad 💯Call Us 🔝 9352988975 🔝💃Top C...
🚺ANJALI MEHTA High Profile Call Girls Ahmedabad 💯Call Us 🔝 9352988975 🔝💃Top C...
dulbh kashyap
 
Determination of Equivalent Circuit parameters and performance characteristic...
Determination of Equivalent Circuit parameters and performance characteristic...Determination of Equivalent Circuit parameters and performance characteristic...
Determination of Equivalent Circuit parameters and performance characteristic...
pvpriya2
 
3rd International Conference on Artificial Intelligence Advances (AIAD 2024)
3rd International Conference on Artificial Intelligence Advances (AIAD 2024)3rd International Conference on Artificial Intelligence Advances (AIAD 2024)
3rd International Conference on Artificial Intelligence Advances (AIAD 2024)
GiselleginaGloria
 
Call Girls In Tiruppur 👯‍♀️ 7339748667 🔥 Free Home Delivery Within 30 Minutes
Call Girls In Tiruppur 👯‍♀️ 7339748667 🔥 Free Home Delivery Within 30 MinutesCall Girls In Tiruppur 👯‍♀️ 7339748667 🔥 Free Home Delivery Within 30 Minutes
Call Girls In Tiruppur 👯‍♀️ 7339748667 🔥 Free Home Delivery Within 30 Minutes
kamka4105
 
Literature review for prompt engineering of ChatGPT.pptx
Literature review for prompt engineering of ChatGPT.pptxLiterature review for prompt engineering of ChatGPT.pptx
Literature review for prompt engineering of ChatGPT.pptx
LokerXu2
 
Call For Paper -3rd International Conference on Artificial Intelligence Advan...
Call For Paper -3rd International Conference on Artificial Intelligence Advan...Call For Paper -3rd International Conference on Artificial Intelligence Advan...
Call For Paper -3rd International Conference on Artificial Intelligence Advan...
ijseajournal
 
Intuit CRAFT demonstration presentation for sde
Intuit CRAFT demonstration presentation for sdeIntuit CRAFT demonstration presentation for sde
Intuit CRAFT demonstration presentation for sde
ShivangMishra54
 
INTRODUCTION TO ARTIFICIAL INTELLIGENCE BASIC
INTRODUCTION TO ARTIFICIAL INTELLIGENCE BASICINTRODUCTION TO ARTIFICIAL INTELLIGENCE BASIC
INTRODUCTION TO ARTIFICIAL INTELLIGENCE BASIC
GOKULKANNANMMECLECTC
 
natural gas transmission pipeline safety related presentation.pdf
natural gas transmission pipeline safety related presentation.pdfnatural gas transmission pipeline safety related presentation.pdf
natural gas transmission pipeline safety related presentation.pdf
SusheelGupta16
 
BBOC407 Module 1.pptx Biology for Engineers
BBOC407  Module 1.pptx Biology for EngineersBBOC407  Module 1.pptx Biology for Engineers
BBOC407 Module 1.pptx Biology for Engineers
sathishkumars808912
 
openshift technical overview - Flow of openshift containerisatoin
openshift technical overview - Flow of openshift containerisatoinopenshift technical overview - Flow of openshift containerisatoin
openshift technical overview - Flow of openshift containerisatoin
snaprevwdev
 
Technological Innovation Management And Entrepreneurship-1.pdf
Technological Innovation Management And Entrepreneurship-1.pdfTechnological Innovation Management And Entrepreneurship-1.pdf
Technological Innovation Management And Entrepreneurship-1.pdf
tanujaharish2
 

Recently uploaded (20)

This study Examines the Effectiveness of Talent Procurement through the Imple...
This study Examines the Effectiveness of Talent Procurement through the Imple...This study Examines the Effectiveness of Talent Procurement through the Imple...
This study Examines the Effectiveness of Talent Procurement through the Imple...
 
Update 40 models( Solar Cell ) in SPICE PARK(JUL2024)
Update 40 models( Solar Cell ) in SPICE PARK(JUL2024)Update 40 models( Solar Cell ) in SPICE PARK(JUL2024)
Update 40 models( Solar Cell ) in SPICE PARK(JUL2024)
 
Mahipalpur Call Girls Delhi 🔥 9711199012 ❄- Pick Your Dream Call Girls with 1...
Mahipalpur Call Girls Delhi 🔥 9711199012 ❄- Pick Your Dream Call Girls with 1...Mahipalpur Call Girls Delhi 🔥 9711199012 ❄- Pick Your Dream Call Girls with 1...
Mahipalpur Call Girls Delhi 🔥 9711199012 ❄- Pick Your Dream Call Girls with 1...
 
Call Girls Chennai +91-8824825030 Vip Call Girls Chennai
Call Girls Chennai +91-8824825030 Vip Call Girls ChennaiCall Girls Chennai +91-8824825030 Vip Call Girls Chennai
Call Girls Chennai +91-8824825030 Vip Call Girls Chennai
 
Impartiality as per ISO /IEC 17025:2017 Standard
Impartiality as per ISO /IEC 17025:2017 StandardImpartiality as per ISO /IEC 17025:2017 Standard
Impartiality as per ISO /IEC 17025:2017 Standard
 
CSP_Study - Notes (Paul McNeill) 2017.pdf
CSP_Study - Notes (Paul McNeill) 2017.pdfCSP_Study - Notes (Paul McNeill) 2017.pdf
CSP_Study - Notes (Paul McNeill) 2017.pdf
 
SPICE PARK JUL2024 ( 6,866 SPICE Models )
SPICE PARK JUL2024 ( 6,866 SPICE Models )SPICE PARK JUL2024 ( 6,866 SPICE Models )
SPICE PARK JUL2024 ( 6,866 SPICE Models )
 
Asymmetrical Repulsion Magnet Motor Ratio 6-7.pdf
Asymmetrical Repulsion Magnet Motor Ratio 6-7.pdfAsymmetrical Repulsion Magnet Motor Ratio 6-7.pdf
Asymmetrical Repulsion Magnet Motor Ratio 6-7.pdf
 
🚺ANJALI MEHTA High Profile Call Girls Ahmedabad 💯Call Us 🔝 9352988975 🔝💃Top C...
🚺ANJALI MEHTA High Profile Call Girls Ahmedabad 💯Call Us 🔝 9352988975 🔝💃Top C...🚺ANJALI MEHTA High Profile Call Girls Ahmedabad 💯Call Us 🔝 9352988975 🔝💃Top C...
🚺ANJALI MEHTA High Profile Call Girls Ahmedabad 💯Call Us 🔝 9352988975 🔝💃Top C...
 
Determination of Equivalent Circuit parameters and performance characteristic...
Determination of Equivalent Circuit parameters and performance characteristic...Determination of Equivalent Circuit parameters and performance characteristic...
Determination of Equivalent Circuit parameters and performance characteristic...
 
3rd International Conference on Artificial Intelligence Advances (AIAD 2024)
3rd International Conference on Artificial Intelligence Advances (AIAD 2024)3rd International Conference on Artificial Intelligence Advances (AIAD 2024)
3rd International Conference on Artificial Intelligence Advances (AIAD 2024)
 
Call Girls In Tiruppur 👯‍♀️ 7339748667 🔥 Free Home Delivery Within 30 Minutes
Call Girls In Tiruppur 👯‍♀️ 7339748667 🔥 Free Home Delivery Within 30 MinutesCall Girls In Tiruppur 👯‍♀️ 7339748667 🔥 Free Home Delivery Within 30 Minutes
Call Girls In Tiruppur 👯‍♀️ 7339748667 🔥 Free Home Delivery Within 30 Minutes
 
Literature review for prompt engineering of ChatGPT.pptx
Literature review for prompt engineering of ChatGPT.pptxLiterature review for prompt engineering of ChatGPT.pptx
Literature review for prompt engineering of ChatGPT.pptx
 
Call For Paper -3rd International Conference on Artificial Intelligence Advan...
Call For Paper -3rd International Conference on Artificial Intelligence Advan...Call For Paper -3rd International Conference on Artificial Intelligence Advan...
Call For Paper -3rd International Conference on Artificial Intelligence Advan...
 
Intuit CRAFT demonstration presentation for sde
Intuit CRAFT demonstration presentation for sdeIntuit CRAFT demonstration presentation for sde
Intuit CRAFT demonstration presentation for sde
 
INTRODUCTION TO ARTIFICIAL INTELLIGENCE BASIC
INTRODUCTION TO ARTIFICIAL INTELLIGENCE BASICINTRODUCTION TO ARTIFICIAL INTELLIGENCE BASIC
INTRODUCTION TO ARTIFICIAL INTELLIGENCE BASIC
 
natural gas transmission pipeline safety related presentation.pdf
natural gas transmission pipeline safety related presentation.pdfnatural gas transmission pipeline safety related presentation.pdf
natural gas transmission pipeline safety related presentation.pdf
 
BBOC407 Module 1.pptx Biology for Engineers
BBOC407  Module 1.pptx Biology for EngineersBBOC407  Module 1.pptx Biology for Engineers
BBOC407 Module 1.pptx Biology for Engineers
 
openshift technical overview - Flow of openshift containerisatoin
openshift technical overview - Flow of openshift containerisatoinopenshift technical overview - Flow of openshift containerisatoin
openshift technical overview - Flow of openshift containerisatoin
 
Technological Innovation Management And Entrepreneurship-1.pdf
Technological Innovation Management And Entrepreneurship-1.pdfTechnological Innovation Management And Entrepreneurship-1.pdf
Technological Innovation Management And Entrepreneurship-1.pdf
 

Join operation

  • 1.
  • 2. Different algorithm to implement joins are Nested-loop join Block nested-loop join Indexed nested-loop join Merge join Hash join Choice based on cost estimate Example Number of records of customer 10,000 depositor 5000 Number of blocks of customer 40 depositor 100
  • 3. 1.Nested-loop join A nested loop join is a naive algorithm that joins two sets by using two nested loops. Join operations are important to database management. Algorithm: Two relations and are joined as follows: For each tuple r in R do For each tuple s in S do If r and s satisfy the join condition Then output the tuple <r,s>
  • 4. This algorithm will involve nr*bs+ br block transfers and nr+br seeks, where br and bs are number of blocks in relations r and s respectively, and nr is the number of tuples in relation r. The algorithm runs in I/Os, where and is the number of tuples contained in and respectively. Can easily be generalized to join any number of relations. The block nested loop join algorithm is a generalization of the simple nested loops algorithm that takes advantage of additional memory to reduce the number of times that the relation is scanned.
  • 5. 2.Block nested-loop join Algorithm: for each block BR of R do begin for each block BS of S do begin for each tuple tR in BR do for each tuple tS in BS do check whether pair (tR; tS) satises join condition if they do, add tR tS to the result end end end end Also requires no indexes and can be used with any kind of join condition. Worst case: db buffer can only hold one block of each relation =) br*bs+br disk accesses. Best case: both relations t into db buffer =) br+bs disk accesses. If smaller relation completely ts into db buffer, use that as inner relation. Reduces the cost estimate to BR + BS disk accesses.
  • 6. 3. Index Nested-Loop Join  If an index is available on the inner loop's join attribute and join is an equi-join or natural join, more efficient index lookups can replace scans.  It is even possible (reasonable) to construct index just to compute a join.  For each tuple tr in the outer relation R, use the index to lookup tuples in S that satisfy join condition with tr  Worst case: db buffer has space for only one page of R and one page of the index associated with S:  br disk accesses to read R, and for each tuple in R, perform index lookup on S.  Cost of the join: br+nr*c, where c is the cost of a single selection on S using the join condition.  If indexes are available on both R and S, use the one with the fewer tuples as the outer relation.
  • 7. 4.Merge Join Basic idea: first sort both relations on join attribute (if not already sorted this way)  Join steps are similar to the merge stage in the external sort-merge algorithm (discussed later)  Every pair with same value on join attribute must be matched. values of join attributes Relation R Relation S 1 2 2 3 4 5 1 2 3 3 5
  • 8. If no repeated join attribute values, each tuple needs to be read only once. As a result, each block is read only once. Thus, the number of block accesses is BR + BS (plus the cost of sorting, if relations are unsorted). Worst case: all join attribute values are the same. Then the number of block accesses is br*bs+br If one relation is sorted and the other has a secondary B+- tree index on the join attribute, a hybrid merge-join is possible. The sorted relation is merged with the leaf node entries of the B+-tree. The result is sorted on the addresses (rids) of the unsorted relation's tuples, and then the addresses can be replaced by the actual tuples efficiently.
  • 9. 5.Hash-Join only applicable in case of equi-join or natural join A hash function is used to partition tuples of both relations into sets that have the same hash value on the join attribute Partitioning Phase: 2 * Br+Bs block accesses Matching Phase: Br+Bs block accesses (under the assumption that one partition of each relation ts into the database buffer)
  • 10. OTHER OPERATIONS Duplicate Elimination Sorting: remove all but one copy of tuples having identical value(s) on projection attribute(s) Hashing: partition relation using hash function on projection attribute(s); then read partitions into buffer and create in-memory hash index; tuple is only inserted into index if not already present
  • 11. Set Operations: Sorting or hashing Hashing: Partition both relations using the same hash function; use in-memory index for partitions Ri R U S: if tuple in Ri or in Si, add tuple to result ∩: if tuple in Ri and in Si, . . . - : if tuple in Ri and not in Si, . . .
  • 12. Grouping and aggregation: Compute groups via sorting or hashing. Hashing: while groups (partitions) are built, compute partial aggregate values (for group attribute A, V(A,R) tuples to store values)
  • 13. Evaluation of Expressions Alternatives for evaluating an entire expression tree are Materialization: generate results of an expression whose inputs are relations or are already computed, materialize it on disk. repeat Pipelining: pass on tuples to parent operations even as an operation is being executed.
  • 14. Evaluation of Expressions Strategy 1: materialization. Evaluate one operation at a time, starting at the lowest level. Use intermediate results materialized in temporary relations to evaluate next level operation(s). Example: in figure below, compute and store. σ balance<2500(account) the store its join with customer and finally compute the projections on customer name. Лcustomer name ∞ Лbalance<2500 customer account
  • 15.  Materialized evaluation is always applicable. Cost of writing results to disk and editing them back can be quite high. overall cost = sum of cost of individual operations + cost of writing intermediate results to disk. Double Buffering: use two O/P buffer for each operation, when one is full write it to disk while the other is getting filled, reduced execution time.
  • 16. Strategy 2: pipelining. evaluate several operations simultaneously, and pass the result (tuple- or block-wise)on to the next operation. In the example above, once a tuple from OFFERS satisfying selection condition has been found, pass it on to the join. Similarly, don't store result of (final) join, but pass tuples directly to projection. Much cheaper than materialization, because temporary relations are not generated and stored on disk.
  • 17. Pipelining is not always possible, e.g., for all operations that include sorting (blocking operation). Pipelining can be executed in either demand driven or producer driven fashion.
  • 18. DATABASE TUNINIG Tuning: The process of continuing to revise/adjust the physical database design by monitoring resource utilization as well as internal DBMS processing to reveal bottlenecks such as contention for the same data or devices. Goal: To make application run faster To lower the response time of queries/transactions To improve the overall throughput of transactions
  • 19. Tuning Indexes Reasons to tuning indexes Certain queries may take too long to run for lack of an index; Certain indexes may not get utilized at all; Certain indexes may be causing excessive overhead because the index is on an attribute that undergoes frequent changes Options to tuning indexes Drop or/and build new indexes Change a non-clustered index to a clustered index (and vice versa) Rebuilding the index
  • 20. Tuning the Database Design Dynamically changed processing requirements need to be addressed by making changes to the conceptual schema if necessary and to reflect those changes into the logical schema and physical design. Tuning Queries Indications for tuning queries A query issues too many disk accesses The query plan shows that relevant indexes are not being used.
  翻译: