Professional Documents
Culture Documents
DW
DW
There
are three joining techniques.
Best case:
When the outer table qualifying rows are less than the dinner table rows.
Worst Case:
When the outer table rows are more than the inner table rows.
Sort-Merge Table:
✔ Sort operation
✔ Merge operation
Best case:
If u has two tables and both are pre-sorted and fit in memory. The cost u
has to calculate is only merge cost.
Worst case:
If u has two tables and both are not pre-sorted and not fit in memory. The
cost u has to calculate is sorting cost + merge cost.
Examples:
If u have available memory k=150kb, one table R=100kb and other table
S=50kb.the tables are not sorted,then calculate i/o cost?
Sorting cost=r+s=100+50=300kb
Merge cost= r+ s=100+50=300kb
In this case the available memory is small and table size is large so we do
sort ,partition and merge.
(R*log(r/k)+(S*log(s/k))+(r+s)
(100*log(100/25))+(50*log(50/25))+(R+S)=
Hash joins:
No sorting is required
Best case:
Worst case:
Examples:
If u have available memory k=150kb, one table R=100kb and other table
S=50kb.calculate i/o cost=?
If u have available memory k=25kb, one table R=100kb and other table
S=50kb.the tables are not sorted, then calculate i/o cost?
In this case the available memory is small and table size is large so we do
partition and merge.
(R*log(s/k)+(S*log(s/k))+(r+s)
(100*log(50/25))+(50*log(50/25))+(100+50)=