A data analyst needs to combine two large fact tables named invoice_2024 and invoice_2025, each holding the same 15 columns and more than three million rows. Because invoice numbers are sequentially generated and never reused, the business has confirmed there will be no duplicate records across the two tables. The merged result will feed year-over-year revenue dashboards, so the SQL written for the merge step must minimize extra processing such as sorting or de-duplication. Which SQL construct should the analyst use to build the consolidated data set with the least overhead?
Use a UNION ALL operator to append invoice_2025 to invoice_2024.
Merge the tables with a FULL OUTER JOIN on invoice_number.
Create an INNER JOIN between the tables on invoice_number.
Use a UNION operator so that only distinct rows are returned.
UNION ALL simply appends the rows from one query result set to another without performing the duplicate-elimination sort that a plain UNION must execute. When the analyst knows that duplicate rows cannot exist-as in separate yearly invoice tables-UNION ALL avoids the expensive sort/merge phase and therefore runs faster on large row counts. Using UNION would trigger an unnecessary DISTINCT operation; either type of JOIN would produce a wider result that repeats columns and requires join logic rather than a vertical append, adding complexity without benefit in this scenario.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is the difference between UNION and UNION ALL in SQL?
Open an interactive chat with Bash
Why are joins like INNER JOIN or FULL OUTER JOIN not suitable for this scenario?
Open an interactive chat with Bash
What scenarios would be better suited for the UNION operator instead of UNION ALL?
Open an interactive chat with Bash
CompTIA Data+ DA0-002 (V2)
Data Acquisition and Preparation
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
Pass with Confidence.
IT & Cybersecurity Package
You have hit the limits of our free tier, become a Premium Member today for unlimited access.
Military, Healthcare worker, Gov. employee or Teacher? See if you qualify for a Community Discount.
Monthly
$19.99 $11.99
$11.99/mo
Billed monthly, Cancel any time.
$19.99 after promotion ends
3 Month Pass
$44.99 $26.99
$8.99/mo
One time purchase of $26.99, Does not auto-renew.
$44.99 after promotion ends
Save $18!
MOST POPULAR
Annual Pass
$119.99 $71.99
$5.99/mo
One time purchase of $71.99, Does not auto-renew.
$119.99 after promotion ends
Save $48!
BEST DEAL
Lifetime Pass
$189.99 $113.99
One time purchase, Good for life.
Save $76!
What You Get
All IT & Cybersecurity Package plans include the following perks and exams .