Temporary Query Objects

Temporary tables, table variables, CTEs, and related structures.

17 associated posts15 primary posts

Performance Tuning

[Video] How to Troubleshoot Someone Else’s Temp Table Contents

Let's say you need to troubleshoot someone's query performance, and they're using temp tables. You want to peek in at their temp table contents from another session while their query is running. SQL Server makes that a little bit challenging. Nic Neufeld showed how to use DBCC PAGE to do this, but today I'm going to cover another way: reading their statistics histogram.

Read more about [Video] How to Troubleshoot Someone Else’s Temp Table Contents 2 comments — Join the discussion
Performance Tuning

Paul White Explains Temp Table Caching 3 Ways

Paul White (Blog, @SQL_Kiwi) is a legendary SQL Server blogger who's written a ton of good material. You should read all of it. You won't, and I can say that with authority because...I don't read it all either. It's too much.

But when your job eventually requires you to understand temp tables way better than you do today, read these 3 posts in this order - which is probably different than what Paul would recommend, but I think they flow better this way:

Read more about Paul White Explains Temp Table Caching 3 Ways 2 comments — Join the discussion
Performance Tuning

How to Get Better Estimates for Modification Queries

When you're doing DUI operations against tables with millions of rows, you have to be really careful about SQL Server's estimates. Ideally, you want your delete/update/insert (what - what'd you think I meant?) queries to be as simple as possible - even a simple join can cause SQL Server to do wildly, wildly incorrect estimates, which affects memory grants, parallelism, wide vs narrow plans, and more.

Read more about How to Get Better Estimates for Modification Queries 4 comments — Join the discussion
Performance Tuning

Creating Tables and Stored Procedures in TempDB – Permanently

No, not #tables - actual tables. Here's how: [crayon-6a6eb7fe5e990754090862/] The first one disappears when my session is over, but the latter two persist until the SQL Server is restarted. Why would you ever do the latter two? Say you need to share data between sessions, or between different applications, or staging tables for a data…

Read more about Creating Tables and Stored Procedures in TempDB – Permanently 47 comments — Join the discussion
Performance Tuning

Temp Tables vs Table Variables vs Memory Optimized Table Variables [Video]

Should you use temp tables or table variables in your code? Join Microsoft Certified Master Kendra Little to learn the pros and cons of each structure, and take a sneak peek at new Memory Optimized Table Variables in SQL Server 2014.

This video is a recording of a live webcast, so please excuse any audio and video imperfections. Want the scripts from the webcast? Scroll on down.

Read more about Temp Tables vs Table Variables vs Memory Optimized Table Variables [Video] 7 comments — Join the discussion
Performance Tuning

Are Table Variables as Good as Temporary Tables in SQL 2014?

There's a couple of new features in SQL Server 2014 that provide options for how you work with temporary objects. Will inline index creation or memory optimized temporary tables forever change the way you code? Let's take a look! Inline Index Creation SQL Server 2014 brings us a TSQL improvement called "inline specification of CLUSTERED…

Read more about Are Table Variables as Good as Temporary Tables in SQL 2014? 31 comments — Join the discussion