performance of union versus union all

后端 未结 5 2065
忘掉有多难
忘掉有多难 2020-12-18 18:55

I have to run a select statement across several tables. I am sure the tables return different records. I am anyway using UNION ALL.

Is it better to use UNION or of U

5条回答
  •  被撕碎了的回忆
    2020-12-18 19:10

    Why is UNION ALL faster? Because UNION must do a sort to remove the duplicates. If you do not need to remove duplicates then UNION ALL is the better option, however UNION does have a purpose and should be used when appropriate.

提交回复
热议问题