开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜