4.4 Join Index Selection 67
algorithm is faster than nested-loop. We assume the complexity of the sort of nb blocks
is approximately 2 × nb × log
3
nb for a three-way sort, and that project has one buffer
(250 rows) and assignedTo has 77 buffers (50,000 rows), as shown in Figure 4.2.
Sort-merge join Case 1: Both project and assignedTo are already ordered by pro-
jectName.
join I/O time = merge time (to scan both tables)
= (77 buffers + 1 buffer) × 5.8 ms
= .45 seconds.
Sort-merge join Case 2: Only project is ordered by projectName.
join I/O time = sort time for assignedTo +
merge time (to scan both sorted tables)
= (2 × 77 × log
3
77 + 77 + 1 buffer accesses) × 5.8 ms
= (2 × 77 × 3.954 + 78) × 5.8 ms
= 3.98 seconds.
Sort-merge join Case 3: Neither project ...