Read our blogs, tips and tutorials
Try our exercises or test your skills
Watch our tutorial videos or shorts
Take a self-paced course
Read our recent newsletters
License our courseware
Book expert consultancy
Buy our publications
Get help in using our site
538 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owl trainers only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Search our website
We also send out useful tips in a monthly email newsletter ...
Speed comparison of temporary tables against table variables Part five of a five-part series of blogs |
---|
When you are programming in SQL, you often have the choice of using table variables or temporary tables. This blog considers whether one method is substantially quicker than the other (spoiler alert: not really). |
Here are the results from running the two queries (the times shown are in seconds, as recorded in SQL Server Management Studio):
Temporary tables | Table variables | |
---|---|---|
100,000 rows | 2 seconds | 2 seconds |
1,000,000 rows | 14 seconds | 18 seconds |
3,000,000 rows | 60 seconds | 72 seconds |
5,000,000 rows | 190 seconds | 208 seconds |
What this shows is that it doesn't really matter which method you use - the results are similar.
My personal preference is to use table variables - I like the fact that you have to define their structure at the start, and you know they won't exist when your query finishes.
Parts of this blog |
---|
Some other pages relevant to the above blogs include:
Kingsmoor House
Railway Street
GLOSSOP
SK13 2AA
Landmark Offices
99 Bishopsgate
LONDON
EC2M 3XD
Holiday Inn
25 Aytoun Street
MANCHESTER
M1 3AE
© Wise Owl Business Solutions Ltd 2024. All Rights Reserved.