Junior
Set Operators
SQL & Databases
Explain UNION vs UNION ALL.
Short answer: UNION removes duplicates (extra sort/distinct cost). UNION ALL keeps all rows and is faster when duplicates are impossible or acceptable.
Default to UNION ALL unless you truly need distinct.
Share this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png