Difference between UNION and UNION ALL
Unions are used to join tables on column level, usually when we need to join two sets from the same table into one result. But what is difference in UNION and UNION ALL?
- simply joins two results and does not do anything else with result set.
- also joins results but selects only distinct rows from each select statement. It means, that UNION in addition excludes duplicate rows. Therefore UNION can be slower than UNION ALL, because has to order data to find duplicates.