Krupp
Krupp

Reputation: 373

MySQL Performance - JOIN ON vs JOIN USING on multiple tables

Speaking in principle, which one is faster:

SELECT FROM t1 INNER JOIN t2 INNER JOIN t3 ON t1.c = t2.c = t3.c

vs

SELECT FROM t1 INNER JOIN t2 USING (c) INNER JOIN t3 USING (c)

Upvotes: 2

Views: 2248

Answers (2)

SeekingDataSec
SeekingDataSec

Reputation: 1

The FROM part of any SQL statement is logically processed first before any other part of SQL statement and both statements are joining in the FROM portion (just don't add the join criteria to a WHERE clause). Assuming both have syntax correct, then the bigger question is whether these are flowing from M:1, M:1 context and whether there are indexes on both primary and foreign keys. Then run them through a query analyzer to gage the actual performance.

Upvotes: 0

Jacobm001
Jacobm001

Reputation: 4539

The easiest way for you to tell this would be to look at your explain plan. If you look at both, you'll probably see zero difference.

The using() keyword here is simply a shorthand expression. It evaluates to the same thing as your other option, and therefore makes no difference to performance.

Upvotes: 5

Related Questions