Databases Reference
In-Depth Information
In step 3, we execute the same query mentioned earlier, but using the
UNION
ALL
operator,
resulting in the following execution plan:
We can see that if we use
UNION
ALL
instead of the
UNION
operator, the
SORT
UNIQUE
operation is not required. Remember that the two operations are similar, but the
UNION
ALL
returns duplicate records, and the
UNION
operator doesn't. When we don't have to worry
about the duplicates (or they are not required by the design), it's better to use the
UNION
ALL
operator to improve performance.