开发者

MySQL: "inner join on" performance: "where" vs adding to "on"

开发者 https://www.devze.com 2023-02-13 05:35 出处:网络
Is there开发者_运维百科 a performance difference between these two? select * from tableA INNER JOIN tableB ON tableA.type = ? AND tableB.ref = tableA.id

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 = ?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消