1

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.

Aura
  • 1,283
  • 2
  • 16
  • 30
  • 1
    Have you profiled/benchmarked the two different approaches? – Dai May 07 '18 at 15:59
  • 1
    Possible duplicate of [Does EXCEPT execute faster than a JOIN when the table columns are the same](https://stackoverflow.com/questions/14693118/does-except-execute-faster-than-a-join-when-the-table-columns-are-the-same) – GSerg May 07 '18 at 15:59

1 Answers1

2

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.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786