Is there any difference in performance in the following?
SELECT person.id
FROM person
LEFT JOIN address ON person.id = address.personID
WHERE address.personID IS NOT NULL
vs
SELECT person.id
FROM person
INNER JOIN address ON person.id = address.personID
This request should display the identifier of a user who has an address record (not all). The logical goal here would be to use Inner Join, as the second example shows. For reasons that are not entirely important (the request is created from the query builder), I may have to use the first approach.
Curious what the effect is. Does MySQL make a lot of unnecessary work when it has a LEFT JOIN, and then compares this field to zero to reduce the set? Maybe how INNER JOIN works behind the scenes?
Brian source
share