Presentation is loading. Please wait.

Presentation is loading. Please wait.

15.3 Nested-Loop Joins By: Saloni Tamotia (215). Introduction to Nested-Loop Joins  Used for relations of any side.  Not necessary that relation fits.

Similar presentations


Presentation on theme: "15.3 Nested-Loop Joins By: Saloni Tamotia (215). Introduction to Nested-Loop Joins  Used for relations of any side.  Not necessary that relation fits."— Presentation transcript:

1 15.3 Nested-Loop Joins By: Saloni Tamotia (215)

2 Introduction to Nested-Loop Joins  Used for relations of any side.  Not necessary that relation fits in main memory  Uses “One-and-a-half” pass method in which for each variation: One argument read just once. Other argument read repeatedly.  Two kinds: Tuple-Based Nested Loop Join Block-Based Nested Loop Join

3 ADVANTAGES OF NESTED-LOOP JOIN  Fits in the iterator framework.  Allows us to avoid storing intermediate relation on disk.

4 Tuple-Based Nested-Loop Join  Simplest variation of the nested-loop join  Loop ranges over individual tuples

5 Tuple-Based Nested-Loop Join  Algorithm to compute the Join R(X,Y) | | S(Y,Z) FOR each tuple s in S DO FOR each tuple r in R DO IF r and s join to make tuple t THEN output t  R and S are two Relations with r and s as tuples.  carelessness in buffering of blocks causes the use of T(R)T(S) disk I/O’s

6 IMPROVEMENT & MODIFICATION To decrease the cost  Method 1: Use algorithm for Index-Based joins We find tuple of R that matches given tuple of S We need not to read entire relation R  Method 2: Use algorithm for Block-Based joins Tuples of R & S are divided into blocks Uses enough memory to store blocks in order to reduce the number of disk I/O’s.

7 Block-Based Nested-Loop Join Algorithm  Access to arguments is organized by block. While reading tuples of inner relation we use less number of I/O’s disk.  Using enough space in main memory to store tuples of relation of the outer loop. Allows to join each tuple of the inner relation with as many tuples as possible.

8 Block-Based Nested-Loop Join Algorithm ALGORITHM: FOR each chunk of M - 1 blocks of S DO FOR each block b of R DO FOR each tuple t of b DO find the tuples of S in memory that join with t output the join of t with each of these tuples

9 Block-Based Nested-Loop Join Algorithm Assumptions: B(S) ≤ B(R) B(S) > M This means that the neither relation fits in the entire main memory.

10 Analysis of Nested-Loop Join Number of disk I/O’s: [B(S)/(M- 1 )]*(M-1 +B(R)) or B(S) + [B(S)B(R)/(M- 1 )] or approximately B(S)*B(R)/M

11 QUESTIONS


Download ppt "15.3 Nested-Loop Joins By: Saloni Tamotia (215). Introduction to Nested-Loop Joins  Used for relations of any side.  Not necessary that relation fits."

Similar presentations


Ads by Google