MySQL Forums
Forum List  »  General

Re: Fastest sql query
Posted by: Rick James
Date: March 10, 2016 10:57PM

Do EXPLAIN EXTENDED SELECT ...; SHOW WARNINGS; -- You may be in for a surprise. I think they will be transformed into the same code.

But...

Don't pick based on "faster"; pick based on "right". The second one is probably "right" in that the JOIN..ON specifies how the tables are related, then the WHERE gives qualifications.

It is up to the Optimizer to do the query in the optimal way. But you have to provide the best indexes:

first_table needs INDEX(name, id) in either order.
tbl_user needs INDEX(int_user_ID)

Options: ReplyQuote


Subject
Written By
Posted
March 10, 2016 03:10AM
March 10, 2016 10:24AM
Re: Fastest sql query
March 10, 2016 10:57PM


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.