performance of union versus union all

后端 未结 5 2040
忘掉有多难
忘掉有多难 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:25

    UNION ALL will perform better than UNION when you're not concerned about eliminating duplicate records because you're avoiding an expensive distinct sort operation. See: SQL SERVER – Difference Between Union vs. Union All – Optimal Performance Comparison

提交回复
热议问题