Why is below 2 query generating different execution plan in MYSQL?
0
votes
1
answer
250
views
Only difference in the below query is the order by column. The resultset of both query is same.
However, the 2nd query execution plan shows 'Using temporary; Using filesort' for ordering where as for 1st query it does not require filesort.
Apart from id I have index on c.table_b_id and c.some_indexed_id
SELECT * FROM TableA a
inner join TableB b on a.id = b.id
inner join TableC c on c.table_b_id = b.id
where c.some_indexed_id = 1
order by c.table_b_id asc;
SELECT * FROM TableA a
inner join TableB b on a.id = b.id
inner join TableC c on c.table_b_id = b.id
where c.indexed_id = 1
order by b.id asc;
Asked by sagar
(1 rep)
Apr 21, 2021, 06:01 AM
Last activity: May 21, 2025, 12:06 PM
Last activity: May 21, 2025, 12:06 PM