UNION and UNION ALL both stack result sets vertically, but they treat duplicates differently — and that difference has a real performance cost that analysts should understand.
Key Points
- UNION removes duplicate rows; UNION ALL keeps everything
- UNION ALL is faster — no deduplication sort is needed
- Both require the same number of columns with compatible types
- Column names come from the first SELECT
- ORDER BY applies to the combined result, at the end
- Use UNION ALL by default; switch to UNION only when duplicates must go
.png)