Is there a performance difference between these two?
select * from tableA INNER JOIN tableB ON tableA.type = ? AND tableB.ref = tableA.id
select * from tableA INNER JOIN tableB ON tableB.ref = tableA.id WHERE tableA.type = ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I’m guessing they will be identical but you can find out for yourself by running EXPLAIN on both of them and looking at the actual plan.
Generally with a declarative language like SQL you aren’t going to be able to find silver bullet optimizations that are so simple. If there were a significant performance advantage for one over the other the optimizer would likely recognize it and run a query plan that used the most efficient technique.