Jump to content

INNER JOIN vs LEFT JOIN WHERE x IS NOT NULL


Jabop

Recommended Posts

I have read some debate on a few sites about the two joins. Most state that LEFT JOIN WHERE x IS NOT NULL is faster and more efficient than an INNER JOIN.

 

I've done a few benches with a few of the tables that I have, at only about 14k records - which I understand isn't much - but I got the same results with both queries.

 

SELECT ac.Referrer, a.Name

FROM advertisementclicks AS ac

LEFT JOIN advertisements AS a ON a.ID = ac.AdvertisementID

WHERE a.ID IS NOT NULL

 

Showing rows 0 - 29 (13,975 total, Query took 0.0011 sec)

 

SELECT ac.Referrer, a.Name

FROM advertisementclicks AS ac

INNER JOIN advertisements AS a ON a.ID = ac.AdvertisementID

Showing rows 0 - 29 (13,975 total, Query took 0.0011 sec)

 

Does anyone have any information on this, care to debunk or back this up, or elaborate?

Link to comment
Share on other sites

There's no difference in this case, the optimizer will figure that out right away... so you're not really testing anything.  The difference will come about when there are NULL values in the join-ed field during the LEFT JOIN.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.