












Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!













1
2
Need for Speed: Join Techniques
4
About Nested-Loop Join
5
FOR i = 1 to N DO BEGIN /* N rows in T1 */
IF i th^ row of T1 qualifies THEN BEGIN For j = 1 to M DO BEGIN /* M rows in T2 */ IF the ith^ row of T1 matches to j th^ row of T2 on join key THEN BEGIN IF the j th^ row of T2 qualifies THEN BEGIN produce output row END END END END END
Nested-Loop Join: Code
7
Nested-Loop Join: Order of Tables
8
Nested-Loop Join: Cost Formula
Join cost = Cost of accessing Table_A +
Table_B to be scanned for each qualifying row
OR
Join cost = Blocks accessed for Table_A +
Blocks accessed for Table_A × Blocks
accessed for Table_B
10
Nested-Loop Join: Variants
11
Sort-Merge Join
13
Table_A Table_B 1 1 2 2 2 4 5 5 5 6 6 6 6 6 7 8 1 3 3 4 4 4 5 5 6 6 6 6 7 7 7 7
Table_A Table_B
1 1 2 2 2 4 5 5 5 6 6 6 6 6 7 8 1 3 3 4 4 4 5 5 6 6 6 6 7 7 7 7
Table_A Table_B
Sort-Merge Join Example Docsity.com
14
Sort-Merge Join: Note
16
Hash-Based Join: Working
17
Hash-Based Join: Example
Table_B on disk
Disk^ Disk
Table_A
hash function
h
...
Table_B
M N
N
2
1
. . .
1
2
. . .
Table_A in main memory
19
Hash-Based Join: Partition Skew
20
Hash-Based Join: Intrinsic Skew