Docsity

Need for Speed, Join Techniques - Data Warehousing - Lecture Slides, Slides of Data Warehousing

Partial preview of the text

Download Need for Speed, Join Techniques - Data Warehousing - Lecture Slides and more Slides Data Warehousing in PDF only on Docsity!

1

Data Warehousing

Lecture-

Need for Speed: Join Techniques

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

GOES TO GRAPHICS

7

Nested-Loop Join: Order of Tables

8

Nested-Loop Join: Cost Formula

Join cost = Cost of accessing Table_A +

of qualifying rows in Table_A × Blocks of

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

GOES TO GRAPHICS

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

Original

Relation

Table_A

hash function

h

Join Result

...

Table_B

M N

N

2

1

. . .

1

2

. . .

Table_A in main memory

MAIN MEMORY

GOES TO GRAPHICS

19

Hash-Based Join: Partition Skew

20

Hash-Based Join: Intrinsic Skew