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.
精彩评论