Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know JOIN on indexed columns are faster than sub-queries in a query result.

I am confused if : JOINs on non-indexed columns are also faster than sub-queries or not.

share|improve this question
up vote 4 down vote accepted

In a query such as this:

  JOIN (SELECT foo, col1 FROM bar) s_sub 
  ON (some_table.col1 = s_sub.col1)

MySQL is able to use an index on some_table.col1. So that it starts with the derived table (full scan), then moves on to some_table using index.

This means it can utilize an index. So a subquery does not altogether negates use of an index.

If no index exists on any relevant column, obviously hard work is done (full scan, join buffer) to make the JOIN.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.