Why is below 2 query generating different execution plan in MYSQL?
The explain depends on which column you using in WHERE clause, the column which are large in size that which doesn't fit in SORT BUFFER requires filesort for sorting purpose. And other point is b.id may be primary key which is sorted by default, So it doesn't requires to do sorting &amp; where c.table_b_id requires sorting.