Rants SQL


Developers absolutely love DISTINCT don’t they? They use them everywhere but often for the wrong reasons. My current pet hate in this area is DISTINCT in UNIONs. I’m guessing they:

  • Don’t realise UNION will give them the DISTINCT list
  • Somehow believe DISTINCT in that part of the UNION will make the statement miraculously faster

None of which are necessarily true – in fact the addition of a DISTINCT can adversely affect execution plans in some cases.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.