Problem Statement
Why can UNION ALL be faster than UNION?
Explanation
UNION performs a distinct operation across inputs, which costs CPU and memory. UNION ALL concatenates results and is usually faster.
Use UNION when you truly need deduplication. Otherwise prefer UNION ALL and dedupe later if needed.
Code Solution
SolutionRead Only
SELECT id FROM a UNION ALL SELECT id FROM b;
