# Nested Loops

This is a common type of processing a join between 2 row sources. First we return all the rows from row source 1, then we probe row source 2 once for each row returned from row source 1.

Row source 1

Row 1 -------------- -- Probe -> Row source 2

Row 2 -------------- -- Probe -> Row source 2

Row 3 -------------- -- Probe -> Row source 2

Row source 1 is known as the outer table. Row source 2 is known as the inner table. Accessing row source 2 is known a probing the inner table. For nested loops to be efficient it is important that the first row source returns as few rows as possible as this directly controls the number of probes of the second row source. Also it helps if the access method for row source 2 is efficient as this operation is being repeated once for every row returned by row source 1.

Parent topic: Common Issues to Be Aware of