Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 729673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:49:25+00:00 2026-05-14T06:49:25+00:00

Generally speaking, for combining a lot of data is it better to use a

  • 0

Generally speaking, for combining a lot of data is it better to use a temp table/temp variable as a staging area or should I just stick to “UNION ALL”?

Assumptions:

  • No further processing is needed, the results are sent directly to the client.
  • The client waits for the complete recordset, so streaming results isn’t necessary.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T06:49:26+00:00Added an answer on May 14, 2026 at 6:49 am

    I would stick to UNION ALL. If there’s no need to do intermediary processing, thus requiring a temp table, then I would not use one.

    Inserting data into a temp table (even if it’s a table variable which despite the myths, is not a purely “in memory” structure) will involve work in tempdb (which can be a bottleneck). To then just SELECT * as-is and return it without any special processing is unnecessary and I think bloats the code. When you just need to return data without any special processing, then a temp table approach seems a bit “round the houses”. If I thought there was a reason to justify the use of a temp table, I would run some like-for-like performance tests to compare with vs without temp tables – then compare the stats (duration, reads, writes, CPU). Doing actual performance tests is the best way to be as confident as possible that whatever approach you choose, is the best. Especially as you don’t have to be using temp tables for there to be work pushed over into tempdb – i.e. depending on your queries, it might involve work in tempdb anyway.

    To clarify, I’m not saying one is better than the other full stop. As with most things, it depends on scenario. In the scenario described, it just sounds like you’d be adding in an extra step which doesn’t seem to add any functional value and I can’t see you’d gain anything other than creating a slightly more complicated/lengthy query.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Generally speaking, the SQL queries that I write return unformatted data and I leave
Generally in programming, the floating point data types should not be compared for equality
Which is a better practice, generally speaking, and why? Under what circumstances would you
Generally speaking goto is bad (we all know why) What would be a better
Generally speaking, the more I use immutable objects in Java the more I'm thinking
Generally speaking, should you do any Browser/Header Caching for dynamic PHP pages? If so,
Generally speaking, individual JavaScript files that a page uses should be combined into a
Generally speaking, should one strive to align a class's dependencies with its imports? For
Generally speaking, a common VB.NET class should look like the following: Public Class MyClassName
Generally speaking, the REST community seems to dislike complex data in GET requests. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.