Two relations R {\displaystyle R} and S {\displaystyle S} are joined as follows:
This algorithm will involve nr*bs+ br block transfers and nr+br seeks, where br and bs are number of blocks in relations R and S respectively, and nr is the number of tuples in relation R.
The algorithm runs in O ( | R | | S | ) {\displaystyle O(|R||S|)} I/Os, where | R | {\displaystyle |R|} and | S | {\displaystyle |S|} is the number of tuples contained in R {\displaystyle R} and S {\displaystyle S} respectively and can easily be generalized to join any number of relations ...
The block nested loop join algorithm2 is a generalization of the simple nested loops algorithm that takes advantage of additional memory to reduce the number of times that the S {\displaystyle S} relation is scanned. It loads large chunks of relation R into main memory. For each chunk, it scans S and evaluates the join condition on all tuple pairs, currently in memory. This reduces the number of times S is scanned to once per chunk.
If the inner relation has an index on the attributes used in the join, then the naive nest loop join can be replaced with an index join.
The time complexity for this variation improves from O ( | R | | S | ) to O ( | R | log | S | ) {\displaystyle O(|R||S|){\text{ to }}O(|R|\log |S|)}
"Understanding Nested Loops Joins". 4 October 2012. https://technet.microsoft.com/en-us/library/ms191318(v=sql.105).aspx ↩
http://www.databaselecture.com/slides/9_Operator_Implementations.pdf [bare URL PDF] http://www.databaselecture.com/slides/9_Operator_Implementations.pdf ↩