Nested loops

One way to join two tables is to use a nested loop. The principle is simple. Here is some pseudo code:

for x in table1: 
for y in table2:
if x.field == y.field
issue row
else
keep doing

Nested loops are often used if one of the sides is very small and contains only a limited set of data. In our example, a nested loop would lead to 100 million x 200 million iterations through the code. This is clearly not an option because the runtime would simply explode.

A nested loop is generally O(n2), so it is only efficient if one side of the join is very small. In this example, this is not the case, so a nested loop can be ruled out to calculate the view.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset