I have two queries that I\'m UNION
ing together such that I already know there will be no duplicate elements between the two queries. Therefore, UNION
a
You should use the one that matches the intent of what you are looking for. If you want to ensure that there are no duplicates use UNION
, otherwise use UNION ALL
. Just because your data will produce the same results right now doesn't mean that it always will.
That said, UNION ALL
will be faster on any sane database implementation, see the articles below for examples. But typically, they are the same except that UNION
performs an extra step to remove identical rows (as one might expect), and it may tend to dominate execution time.