Can anyone tell me which table is considered to be the inner one in a nested loop join? For example if the query is from a inner join b on..., which one, a, or b will be considered inner? I knew that it is b, but from the article at dbsophic, the first example under Small outer loop with a well indexed inner input seems to suggest the reverse.
Can anyone tell me which table is considered to be the inner one in
Share
To be sure…
The choice of inner and outer tables for the physical operator is made by the optimiser and is unrelated to the logical operator.
Now, the nested loop psudeo code is this
So it doesn’t make a difference in theory.
In practice, the optimiser will work out the best way around for inner and outer tables: which is what your article link should describe. A.k.a how to reduce the number of iterations
For completeness…
INNER JOINlogical operator is commutative and associativeSo
A INNER JOIN Bis the same asB INNER JOIN A.There is no inner and outer table here