What is the difference between UNION and UNION ALL?
beginnerAnswer
UNION combines two result sets and removes duplicate rows. UNION ALL combines them and keeps everything.
UNION ALL is faster because deduplication requires a sort or hash across the whole result.
Use UNION ALL by default and only pay for UNION when you actually need distinct rows.
Related