SlideShare a Scribd company logo
1 of 17
B.Tech, CSE & IT, IV/V Sem, II/III Year
CS 502/IT405: Data Base Management System
Archana Tomar
Asst. Prof. ,Department Of Computer Science & Engineering
Unit 3
Cost optimization Technique part-2
Lecture No. 41
Outlines
• Prerequisite
• Cost optimization
• Join Algorithms
• Example
• Exercise
• Learning Outcomes
• References
DBMS
Prerequisite
• Query language
• Relational Algebra operations
• Set operation
Cost Based Optimization
DBMS <SELO: 5,12> <Reference No.: R1,R2> 1
Information about relations and attributes:
• NR: number of tuples
• BR: number of blocks
• SR: size of a tuple of R.
• FR: blocking factor; (FR = [NR/BR])
• V(A, R): number of distinct values
• SC(A, R): selectivity of attribute SC(A, R) = NR/V(A, R).
<Reference No.: R1,R2>
DBMS <SELO: 5,12> 2
Information about indexes:
• HTI: number of levels in index I (B+-tree).
• LBI: number of blocks occupied by leaf nodes in index I (first-level blocks).
• ValI: number of distinct values for the search key
Selection Operation
<Reference No.: R1,R2>
DBMS <SELO: 5,12> 3
σA=a(R)
where a is a constant value,
A an attribute of R
• File Scan
• S1 – Linear search cost(S1)= BR
Continue.
<Reference No.: R1,R2>
DBMS <SELO: 5,12> 4
• S2 – Binary search,
the file ordered based on attribute A (primary index)
cost(S2) = [log2 (BR)] +[SC(A, R)/ FR ] − 1
• If A is primary key, then SC(A, R) = 1, hence cost(S2) = [log2 (BR)].
Join Operations
– Nested-Loop Join
– Block Nested-Loop Join
– Index Nested-Loop Join
– Sort-Merge Join
– Hash-Join
<Reference No.: R1,R2>
DBMS <SELO: 5,12> 5
Nested-Loop Join
Evaluate the condition join R ✶ S
• for each tuple tR in R do begin
for each tuple tS in S do begin
check whether pair (tR, tS) satisfies join condition
if they do, add tR ◦ tS to the result
end
End
<Reference No.: R1,R2>
DBMS <SELO: 5,12> 6
An Improvement: Block Nested-Loop Join
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) satisfies join
condition if they do, add tR ◦ tS to the result
end end end end
<Reference No.: R1,R2>
DBMS <SELO: 5,12> 7
• Example: –
• Compute CUSTOMERS ✶ ORDERS, with CUSTOMERS as the outer relation
<Reference No.: R1,R2>
DBMS <SELO: 5,12> 8
Sort-Merge Join
• first sort both relations on join attribute
• Join steps are similar to the merge stage
<Reference No.: R1,R2>
DBMS <SELO: 5,12> 9
Cost of computing for all joins
Assignment/Exercise
Difference between Nested Loop join and Sort Merge Join
13
DBMS
Learning Outcomes
• Understand about cost based optimization technique.
10
References
1. Korth, Silbertz,Sudarshan, “Fundamental of Database System”, McGraw Hill
2. https://www.cs.ucdavis.edu/~green/courses/ecs165a-w11/8-query.pdf
11
12

More Related Content

Similar to lecture 41 cost optimization.pptx

Relational Database Design
Relational Database DesignRelational Database Design
Relational Database DesignPrabu U
 
Relational Database and Relational Algebra
Relational Database and Relational AlgebraRelational Database and Relational Algebra
Relational Database and Relational AlgebraPyingkodi Maran
 
Relational Algebra and it's Operations pptx
Relational Algebra and it's Operations pptxRelational Algebra and it's Operations pptx
Relational Algebra and it's Operations pptxdanishriasat792
 
Instruction Set Architecture: MIPS
Instruction Set Architecture: MIPSInstruction Set Architecture: MIPS
Instruction Set Architecture: MIPSPrasenjit Dey
 
Lesson 2 network database system
Lesson 2 network database systemLesson 2 network database system
Lesson 2 network database systemGiO Friginal
 
Database Management System Review
Database Management System ReviewDatabase Management System Review
Database Management System ReviewKaya Ota
 
design-compiler.pdf
design-compiler.pdfdesign-compiler.pdf
design-compiler.pdfFrangoCamila
 
AWS December 2015 Webinar Series - Design Patterns using Amazon DynamoDB
AWS December 2015 Webinar Series - Design Patterns using Amazon DynamoDBAWS December 2015 Webinar Series - Design Patterns using Amazon DynamoDB
AWS December 2015 Webinar Series - Design Patterns using Amazon DynamoDBAmazon Web Services
 
Relational algebr
Relational algebrRelational algebr
Relational algebrVisakh V
 
Lecture21-Query-Optimization-1April-2018.pptx
Lecture21-Query-Optimization-1April-2018.pptxLecture21-Query-Optimization-1April-2018.pptx
Lecture21-Query-Optimization-1April-2018.pptxRishabMishra25
 
Introduction to R r.nabati - iausdj.ac.ir
Introduction to R   r.nabati - iausdj.ac.irIntroduction to R   r.nabati - iausdj.ac.ir
Introduction to R r.nabati - iausdj.ac.irnabati
 

Similar to lecture 41 cost optimization.pptx (20)

Amazon DynamoDB 深入探討
Amazon DynamoDB 深入探討Amazon DynamoDB 深入探討
Amazon DynamoDB 深入探討
 
Relational Database Design
Relational Database DesignRelational Database Design
Relational Database Design
 
Relational Database and Relational Algebra
Relational Database and Relational AlgebraRelational Database and Relational Algebra
Relational Database and Relational Algebra
 
Relational Algebra and it's Operations pptx
Relational Algebra and it's Operations pptxRelational Algebra and it's Operations pptx
Relational Algebra and it's Operations pptx
 
Instruction Set Architecture: MIPS
Instruction Set Architecture: MIPSInstruction Set Architecture: MIPS
Instruction Set Architecture: MIPS
 
Lesson 2 network database system
Lesson 2 network database systemLesson 2 network database system
Lesson 2 network database system
 
Database Management System Review
Database Management System ReviewDatabase Management System Review
Database Management System Review
 
Join operation
Join operationJoin operation
Join operation
 
Bit Vectors Siddhesh
Bit Vectors SiddheshBit Vectors Siddhesh
Bit Vectors Siddhesh
 
System Software
System SoftwareSystem Software
System Software
 
Unit 04 dbms
Unit 04 dbmsUnit 04 dbms
Unit 04 dbms
 
design-compiler.pdf
design-compiler.pdfdesign-compiler.pdf
design-compiler.pdf
 
AWS December 2015 Webinar Series - Design Patterns using Amazon DynamoDB
AWS December 2015 Webinar Series - Design Patterns using Amazon DynamoDBAWS December 2015 Webinar Series - Design Patterns using Amazon DynamoDB
AWS December 2015 Webinar Series - Design Patterns using Amazon DynamoDB
 
Lesson11 transactions
Lesson11 transactionsLesson11 transactions
Lesson11 transactions
 
uniT 4 (1).pptx
uniT 4 (1).pptxuniT 4 (1).pptx
uniT 4 (1).pptx
 
Relational algebr
Relational algebrRelational algebr
Relational algebr
 
RDBMS
RDBMSRDBMS
RDBMS
 
Lecture21-Query-Optimization-1April-2018.pptx
Lecture21-Query-Optimization-1April-2018.pptxLecture21-Query-Optimization-1April-2018.pptx
Lecture21-Query-Optimization-1April-2018.pptx
 
Introduction to R r.nabati - iausdj.ac.ir
Introduction to R   r.nabati - iausdj.ac.irIntroduction to R   r.nabati - iausdj.ac.ir
Introduction to R r.nabati - iausdj.ac.ir
 
lecture14.ppt
lecture14.pptlecture14.ppt
lecture14.ppt
 

Recently uploaded

Contact:- 8860008073 Call Girls in Karnal Escort Service Available at Afforda...
Contact:- 8860008073 Call Girls in Karnal Escort Service Available at Afforda...Contact:- 8860008073 Call Girls in Karnal Escort Service Available at Afforda...
Contact:- 8860008073 Call Girls in Karnal Escort Service Available at Afforda...Apsara Of India
 
GV'S 24 CLUB & BAR CONTACT 09602870969 CALL GIRLS IN UDAIPUR ESCORT SERVICE
GV'S 24 CLUB & BAR CONTACT 09602870969 CALL GIRLS IN UDAIPUR ESCORT SERVICEGV'S 24 CLUB & BAR CONTACT 09602870969 CALL GIRLS IN UDAIPUR ESCORT SERVICE
GV'S 24 CLUB & BAR CONTACT 09602870969 CALL GIRLS IN UDAIPUR ESCORT SERVICEApsara Of India
 
VIP Call Girl Kolhapur Aashi 8250192130 Independent Escort Service Kolhapur
VIP Call Girl Kolhapur Aashi 8250192130 Independent Escort Service KolhapurVIP Call Girl Kolhapur Aashi 8250192130 Independent Escort Service Kolhapur
VIP Call Girl Kolhapur Aashi 8250192130 Independent Escort Service KolhapurRiya Pathan
 
Verified Call Girls Esplanade - [ Cash on Delivery ] Contact 8250192130 Escor...
Verified Call Girls Esplanade - [ Cash on Delivery ] Contact 8250192130 Escor...Verified Call Girls Esplanade - [ Cash on Delivery ] Contact 8250192130 Escor...
Verified Call Girls Esplanade - [ Cash on Delivery ] Contact 8250192130 Escor...anamikaraghav4
 
VIP Call Girls Asansol Ananya 8250192130 Independent Escort Service Asansol
VIP Call Girls Asansol Ananya 8250192130 Independent Escort Service AsansolVIP Call Girls Asansol Ananya 8250192130 Independent Escort Service Asansol
VIP Call Girls Asansol Ananya 8250192130 Independent Escort Service AsansolRiya Pathan
 
Dakshineswar Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Se...
Dakshineswar Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Se...Dakshineswar Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Se...
Dakshineswar Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Se...aamir
 
(DIVYA) Dhanori Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(DIVYA) Dhanori Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(DIVYA) Dhanori Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(DIVYA) Dhanori Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
↑Top Model (Kolkata) Call Girls Rajpur ⟟ 8250192130 ⟟ High Class Call Girl In...
↑Top Model (Kolkata) Call Girls Rajpur ⟟ 8250192130 ⟟ High Class Call Girl In...↑Top Model (Kolkata) Call Girls Rajpur ⟟ 8250192130 ⟟ High Class Call Girl In...
↑Top Model (Kolkata) Call Girls Rajpur ⟟ 8250192130 ⟟ High Class Call Girl In...noor ahmed
 
Call Girls Service Bantala - Call 8250192130 Rs-3500 with A/C Room Cash on De...
Call Girls Service Bantala - Call 8250192130 Rs-3500 with A/C Room Cash on De...Call Girls Service Bantala - Call 8250192130 Rs-3500 with A/C Room Cash on De...
Call Girls Service Bantala - Call 8250192130 Rs-3500 with A/C Room Cash on De...anamikaraghav4
 
Low Rate Call Girls Gulbarga Anika 8250192130 Independent Escort Service Gulb...
Low Rate Call Girls Gulbarga Anika 8250192130 Independent Escort Service Gulb...Low Rate Call Girls Gulbarga Anika 8250192130 Independent Escort Service Gulb...
Low Rate Call Girls Gulbarga Anika 8250192130 Independent Escort Service Gulb...Riya Pathan
 
2k Shot Call girls Laxmi Nagar Delhi 9205541914
2k Shot Call girls Laxmi Nagar Delhi 92055419142k Shot Call girls Laxmi Nagar Delhi 9205541914
2k Shot Call girls Laxmi Nagar Delhi 9205541914Delhi Call girls
 
Book Call Girls in Panchpota - 8250192130 | 24x7 Service Available Near Me
Book Call Girls in Panchpota - 8250192130 | 24x7 Service Available Near MeBook Call Girls in Panchpota - 8250192130 | 24x7 Service Available Near Me
Book Call Girls in Panchpota - 8250192130 | 24x7 Service Available Near Meanamikaraghav4
 
Call Girl Nagpur Roshni Call 7001035870 Meet With Nagpur Escorts
Call Girl Nagpur Roshni Call 7001035870 Meet With Nagpur EscortsCall Girl Nagpur Roshni Call 7001035870 Meet With Nagpur Escorts
Call Girl Nagpur Roshni Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
VIP Call Girls Sonagachi - 8250192130 Escorts Service 50% Off with Cash ON De...
VIP Call Girls Sonagachi - 8250192130 Escorts Service 50% Off with Cash ON De...VIP Call Girls Sonagachi - 8250192130 Escorts Service 50% Off with Cash ON De...
VIP Call Girls Sonagachi - 8250192130 Escorts Service 50% Off with Cash ON De...anamikaraghav4
 
Behala ( Call Girls ) Kolkata ✔ 6297143586 ✔ Hot Model With Sexy Bhabi Ready ...
Behala ( Call Girls ) Kolkata ✔ 6297143586 ✔ Hot Model With Sexy Bhabi Ready ...Behala ( Call Girls ) Kolkata ✔ 6297143586 ✔ Hot Model With Sexy Bhabi Ready ...
Behala ( Call Girls ) Kolkata ✔ 6297143586 ✔ Hot Model With Sexy Bhabi Ready ...ritikasharma
 
Call Girls Nashik Gayatri 7001305949 Independent Escort Service Nashik
Call Girls Nashik Gayatri 7001305949 Independent Escort Service NashikCall Girls Nashik Gayatri 7001305949 Independent Escort Service Nashik
Call Girls Nashik Gayatri 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 

Recently uploaded (20)

Contact:- 8860008073 Call Girls in Karnal Escort Service Available at Afforda...
Contact:- 8860008073 Call Girls in Karnal Escort Service Available at Afforda...Contact:- 8860008073 Call Girls in Karnal Escort Service Available at Afforda...
Contact:- 8860008073 Call Girls in Karnal Escort Service Available at Afforda...
 
GV'S 24 CLUB & BAR CONTACT 09602870969 CALL GIRLS IN UDAIPUR ESCORT SERVICE
GV'S 24 CLUB & BAR CONTACT 09602870969 CALL GIRLS IN UDAIPUR ESCORT SERVICEGV'S 24 CLUB & BAR CONTACT 09602870969 CALL GIRLS IN UDAIPUR ESCORT SERVICE
GV'S 24 CLUB & BAR CONTACT 09602870969 CALL GIRLS IN UDAIPUR ESCORT SERVICE
 
VIP Call Girl Kolhapur Aashi 8250192130 Independent Escort Service Kolhapur
VIP Call Girl Kolhapur Aashi 8250192130 Independent Escort Service KolhapurVIP Call Girl Kolhapur Aashi 8250192130 Independent Escort Service Kolhapur
VIP Call Girl Kolhapur Aashi 8250192130 Independent Escort Service Kolhapur
 
Verified Call Girls Esplanade - [ Cash on Delivery ] Contact 8250192130 Escor...
Verified Call Girls Esplanade - [ Cash on Delivery ] Contact 8250192130 Escor...Verified Call Girls Esplanade - [ Cash on Delivery ] Contact 8250192130 Escor...
Verified Call Girls Esplanade - [ Cash on Delivery ] Contact 8250192130 Escor...
 
VIP Call Girls Asansol Ananya 8250192130 Independent Escort Service Asansol
VIP Call Girls Asansol Ananya 8250192130 Independent Escort Service AsansolVIP Call Girls Asansol Ananya 8250192130 Independent Escort Service Asansol
VIP Call Girls Asansol Ananya 8250192130 Independent Escort Service Asansol
 
Dakshineswar Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Se...
Dakshineswar Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Se...Dakshineswar Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Se...
Dakshineswar Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Se...
 
Call Girls South Avenue Delhi WhatsApp Number 9711199171
Call Girls South Avenue Delhi WhatsApp Number 9711199171Call Girls South Avenue Delhi WhatsApp Number 9711199171
Call Girls South Avenue Delhi WhatsApp Number 9711199171
 
(DIVYA) Dhanori Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(DIVYA) Dhanori Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(DIVYA) Dhanori Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(DIVYA) Dhanori Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
↑Top Model (Kolkata) Call Girls Rajpur ⟟ 8250192130 ⟟ High Class Call Girl In...
↑Top Model (Kolkata) Call Girls Rajpur ⟟ 8250192130 ⟟ High Class Call Girl In...↑Top Model (Kolkata) Call Girls Rajpur ⟟ 8250192130 ⟟ High Class Call Girl In...
↑Top Model (Kolkata) Call Girls Rajpur ⟟ 8250192130 ⟟ High Class Call Girl In...
 
Desi Bhabhi Call Girls In Goa 💃 730 02 72 001💃desi Bhabhi Escort Goa
Desi Bhabhi Call Girls  In Goa  💃 730 02 72 001💃desi Bhabhi Escort GoaDesi Bhabhi Call Girls  In Goa  💃 730 02 72 001💃desi Bhabhi Escort Goa
Desi Bhabhi Call Girls In Goa 💃 730 02 72 001💃desi Bhabhi Escort Goa
 
Call Girls Service Bantala - Call 8250192130 Rs-3500 with A/C Room Cash on De...
Call Girls Service Bantala - Call 8250192130 Rs-3500 with A/C Room Cash on De...Call Girls Service Bantala - Call 8250192130 Rs-3500 with A/C Room Cash on De...
Call Girls Service Bantala - Call 8250192130 Rs-3500 with A/C Room Cash on De...
 
Low Rate Call Girls Gulbarga Anika 8250192130 Independent Escort Service Gulb...
Low Rate Call Girls Gulbarga Anika 8250192130 Independent Escort Service Gulb...Low Rate Call Girls Gulbarga Anika 8250192130 Independent Escort Service Gulb...
Low Rate Call Girls Gulbarga Anika 8250192130 Independent Escort Service Gulb...
 
2k Shot Call girls Laxmi Nagar Delhi 9205541914
2k Shot Call girls Laxmi Nagar Delhi 92055419142k Shot Call girls Laxmi Nagar Delhi 9205541914
2k Shot Call girls Laxmi Nagar Delhi 9205541914
 
Call Girls Chirag Delhi Delhi WhatsApp Number 9711199171
Call Girls Chirag Delhi Delhi WhatsApp Number 9711199171Call Girls Chirag Delhi Delhi WhatsApp Number 9711199171
Call Girls Chirag Delhi Delhi WhatsApp Number 9711199171
 
Book Call Girls in Panchpota - 8250192130 | 24x7 Service Available Near Me
Book Call Girls in Panchpota - 8250192130 | 24x7 Service Available Near MeBook Call Girls in Panchpota - 8250192130 | 24x7 Service Available Near Me
Book Call Girls in Panchpota - 8250192130 | 24x7 Service Available Near Me
 
Call Girl Nagpur Roshni Call 7001035870 Meet With Nagpur Escorts
Call Girl Nagpur Roshni Call 7001035870 Meet With Nagpur EscortsCall Girl Nagpur Roshni Call 7001035870 Meet With Nagpur Escorts
Call Girl Nagpur Roshni Call 7001035870 Meet With Nagpur Escorts
 
VIP Call Girls Sonagachi - 8250192130 Escorts Service 50% Off with Cash ON De...
VIP Call Girls Sonagachi - 8250192130 Escorts Service 50% Off with Cash ON De...VIP Call Girls Sonagachi - 8250192130 Escorts Service 50% Off with Cash ON De...
VIP Call Girls Sonagachi - 8250192130 Escorts Service 50% Off with Cash ON De...
 
Behala ( Call Girls ) Kolkata ✔ 6297143586 ✔ Hot Model With Sexy Bhabi Ready ...
Behala ( Call Girls ) Kolkata ✔ 6297143586 ✔ Hot Model With Sexy Bhabi Ready ...Behala ( Call Girls ) Kolkata ✔ 6297143586 ✔ Hot Model With Sexy Bhabi Ready ...
Behala ( Call Girls ) Kolkata ✔ 6297143586 ✔ Hot Model With Sexy Bhabi Ready ...
 
Call Girls Nashik Gayatri 7001305949 Independent Escort Service Nashik
Call Girls Nashik Gayatri 7001305949 Independent Escort Service NashikCall Girls Nashik Gayatri 7001305949 Independent Escort Service Nashik
Call Girls Nashik Gayatri 7001305949 Independent Escort Service Nashik
 
CHEAP Call Girls in Malviya Nagar, (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in  Malviya Nagar, (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in  Malviya Nagar, (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Malviya Nagar, (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 

lecture 41 cost optimization.pptx

  • 1. B.Tech, CSE & IT, IV/V Sem, II/III Year CS 502/IT405: Data Base Management System Archana Tomar Asst. Prof. ,Department Of Computer Science & Engineering Unit 3 Cost optimization Technique part-2 Lecture No. 41
  • 2. Outlines • Prerequisite • Cost optimization • Join Algorithms • Example • Exercise • Learning Outcomes • References DBMS
  • 3. Prerequisite • Query language • Relational Algebra operations • Set operation
  • 4. Cost Based Optimization DBMS <SELO: 5,12> <Reference No.: R1,R2> 1 Information about relations and attributes: • NR: number of tuples • BR: number of blocks • SR: size of a tuple of R. • FR: blocking factor; (FR = [NR/BR]) • V(A, R): number of distinct values • SC(A, R): selectivity of attribute SC(A, R) = NR/V(A, R).
  • 5. <Reference No.: R1,R2> DBMS <SELO: 5,12> 2 Information about indexes: • HTI: number of levels in index I (B+-tree). • LBI: number of blocks occupied by leaf nodes in index I (first-level blocks). • ValI: number of distinct values for the search key
  • 6. Selection Operation <Reference No.: R1,R2> DBMS <SELO: 5,12> 3 σA=a(R) where a is a constant value, A an attribute of R • File Scan • S1 – Linear search cost(S1)= BR
  • 7. Continue. <Reference No.: R1,R2> DBMS <SELO: 5,12> 4 • S2 – Binary search, the file ordered based on attribute A (primary index) cost(S2) = [log2 (BR)] +[SC(A, R)/ FR ] − 1 • If A is primary key, then SC(A, R) = 1, hence cost(S2) = [log2 (BR)].
  • 8. Join Operations – Nested-Loop Join – Block Nested-Loop Join – Index Nested-Loop Join – Sort-Merge Join – Hash-Join <Reference No.: R1,R2> DBMS <SELO: 5,12> 5
  • 9. Nested-Loop Join Evaluate the condition join R ✶ S • for each tuple tR in R do begin for each tuple tS in S do begin check whether pair (tR, tS) satisfies join condition if they do, add tR ◦ tS to the result end End <Reference No.: R1,R2> DBMS <SELO: 5,12> 6
  • 10. An Improvement: Block Nested-Loop Join 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) satisfies join condition if they do, add tR ◦ tS to the result end end end end <Reference No.: R1,R2> DBMS <SELO: 5,12> 7
  • 11. • Example: – • Compute CUSTOMERS ✶ ORDERS, with CUSTOMERS as the outer relation <Reference No.: R1,R2> DBMS <SELO: 5,12> 8
  • 12. Sort-Merge Join • first sort both relations on join attribute • Join steps are similar to the merge stage <Reference No.: R1,R2> DBMS <SELO: 5,12> 9
  • 13. Cost of computing for all joins
  • 14. Assignment/Exercise Difference between Nested Loop join and Sort Merge Join 13 DBMS
  • 15. Learning Outcomes • Understand about cost based optimization technique. 10
  • 16. References 1. Korth, Silbertz,Sudarshan, “Fundamental of Database System”, McGraw Hill 2. https://www.cs.ucdavis.edu/~green/courses/ecs165a-w11/8-query.pdf 11
  • 17. 12