MySQL Forums
Forum List  »  Performance

Re: Left join vs Inner join
Posted by: Rick James
Date: May 10, 2016 07:23PM

LEFT JOIN says that the stuff on the right is 'optional'. And it cannot be looked at until the stuff on the left is done.

JOIN gives the Optimizer the option to _start_ with the stuff on the right.

When JOINing to a ( SELECT ... ) it is best if the optimizer can _start_ with that.

That should explain the timing difference. (I can't follow the query, so I don't have advice on how to retain LEFT but get better performance.)

Try putting that subquery into a TEMPORARY TABLE, and give it a suitable INDEX (or PRIMARY KEY, if possible). Then use that table in the LEFT JOIN.

Options: ReplyQuote


Subject
Views
Written By
Posted
1943
May 09, 2016 06:10PM
948
May 10, 2016 10:40AM
Re: Left join vs Inner join
921
May 10, 2016 07:23PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.