Thinking of an Inner Join as a Cross Join and then satisfying some condition(s)?
- by Jian Lin
It seems like the safest way to think of an Inner Join is to think of it as a Cross Join and then satisfying some condition(s)?
Because the equi-join can be obvious, but the non-equi-join can be a bit confusing.
But if we always use the Cross Join, and then filter out the ones satisfying the condition, then we get the resulting table.
In other words, we can always analyze it by using the first record on the left table, and then go through every single records on the right, and then repeat that for 2nd record on the left, and for the 3rd, 4th, ... etc.
So in our mind, we can analyze it using this way, and it is like O(n^2), although what happens in the DBMS maybe that it is a lot faster (when an index is present).
Is there another good way to think of it besides this method?