Slideshow:
The zig-zag join algorithm using a clustering index:
while ( R ≠ empty and S ≠ empty ) do { Read the index entries of R with the smallest key r : Read the index entries of S with the smallest key s : if ( search key r < search key s ) { discard all search keys r; (and repeat...) } else if ( search key s < search key r ) { discard all search keys s; (and repeat....) } if ( search key s = search key r ) { Read in all tuples of R with smallest search key (r) into M-1 buffers: Use 1 buffer to read in all tuples of S with same join value; Join the tuples in Buf(R) and Buf(S): Join all tuples in Buf(R) and Buf(S); After joining: discard search keys r and s in Buf(R) and Buf(S); (Repeat....) } } |
|
For relation R: 1. Read the ordered clustering index file Index files are relatively small So: we will ignore this cost 2. For each search key value: (index is clustering) B(R) read ------- data block to access the joining tuples V(R,Y) 3. # different search key values = V(R,Y) # blocks accessed for relation R: B(R) V(R,Y) × ------ = B(R) disk blocks V(R,Y) |