Should SQL JOINs be placed in particular order for performance reasons?

The documentation for MySQL states "The join optimizer calculates the order in which tables should be joined".

This order is determined based on information about the sizes of the tables and other factors, such as the presence of indexes.

You should put the joins in the order that makes the most sense for reading and maintaining the query.


The Optimizer does its job well in small queries or in small databases only. But it usually doesn't work very well on large tables and complex queries. So in my experience the answer is:

  • You can forget about the order of the joins if they are a few and / or the database is small.

  • You have to carefully order the joins from the one which will cut off the most of the data to the one which is affecting not much the quantity of data to be managed if your tables are containing millions of rows and / or the joins you are making are many.


My guess is that there wouldn’t be a performance hit. The query optimizer should determine that the join between t2 and t1 is invalid and resolve all dependency joins to a constant value which would mean they would not get evaluated.