To union or union all, that is the question

前端 未结 5 1438
有刺的猬
有刺的猬 2021-02-20 16:38

I have two queries that I\'m UNIONing together such that I already know there will be no duplicate elements between the two queries. Therefore, UNION a

5条回答
  •  难免孤独
    2021-02-20 17:36

    I see that you've tagged this question PERFORMANCE, so I assume that's your primary consideration.

    UNION ALL will absolutely outperform UNION since SQL doesn't have to check the two sets for dups.

    Unless you need SQL to perform the duplicate checking for you, always use UNION ALL.

提交回复
热议问题