0

While putting up the SQL Inner join, which table should be defined as the left table and which one as the Right table. Does the size of the table is a determinant in the same. Please explain.

I am asking this question from the performance/ Optimization point of View.

1 Answers1

3

The answer is that for an inner join the order of tables should not strictly matter. The MySQL query optimizer will make the decision about which table should come first. The reason the order of the inner join does not matter is that the result set consists of the common records from both tables.

Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360
  • I was asked this question in an interview. I mentioned the same thing, but he was not satisfied with this answer and asked me to think again. – Apoorvaa Singh Mar 16 '18 at 09:23
  • The real answer is whatever order is fastest is what will be used. If, for example, you only had indices for one direction, that would likely be the order used. Not much more to explain. – Tim Biegeleisen Mar 16 '18 at 09:25