Aura
Aura

Reputation: 1307

Left join vs EXCEPT

I am trying to create a stored procedure that calculates difference between a large table's last week's version vs this week's version (Current data).

Both LEFT JOIN and EXCEPT will eventually give same results. However I would like to know if there is a preferred approach to do so in terms of performance.

Upvotes: 2

Views: 2473

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1270573

LEFT JOIN and EXCEPT do not produce the same results.

EXCEPT is set operator that eliminates duplicates. LEFT JOIN is a type of join, that can actually produce duplicates. It is not unusual in SQL that two different things produce the same result set for a given set of input data.

I would suggest that you use the one that best fits your use-case. If both work, test which one is faster and use that.

Upvotes: 4

Related Questions