If there is an index (or hash function) on the join attributes of the inner relation, then we
can replace the inefficient file scan with an index lookup. For each tuple in R, we use the
index to retrieve the matching tuples of S. The indexed nested loop join algorithm is outlined
in Figure 21.9. For clarity, we use a simplified algorithm that processes the outer loop
a block at a time. As noted above, however, we should read as many blocks of R into the
database buffer as possible. We leave this modification of the algorithm as an exercise for
the reader (see Exercise 21.19).