Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have been doing some .net performance tests on a bunch of different data access frameworks.

One of the things I've noticed is that performance when accessing the tempdb table in SQL is much quicker than when using a regular table. I'm not too sure why this is but it appears that when entityFramwork (one of the frameworks) sets up its connection with

-- network protocol: TCP/IP
set quoted_identifier on
set arithabort off
set numeric_roundabort off
set ansi_warnings on
set ansi_padding on
set ansi_nulls on
set concat_null_yields_null on
set cursor_close_on_commit off
set implicit_transactions off
set language us_english
set dateformat mdy
set datefirst 7
set transaction isolation level read committed

The performance is reduced to that of a regular table.

Does anyone have any idea why this would be?

share|improve this question
up vote 0 down vote accepted

The BOL help page for tempdb lists the performance improvements made for accessing tempdb.

That said, there are two settings in your list that will have impact on how code is executed: implicit_transactions and the transaction isolation level.

Since read committed is the default transaction isolation level, my guess would be that setting implicit_transactions to off somehow forces tempdb accesses through an extra step that is avoided when doing implicit transactions.

Test it to be sure.

EDIT: as an aside, consider doing really time-critical temporary calculations in a table variable; this is memory-only and hence a factor 100 to 1000 faster than tempdb...

The downside is that there is an obvious point of diminishing returns, as table variables don't have indexes.

share|improve this answer
The piece about table variables being memory-only isn't always true. Under memory pressure table variables can also be paged out. Another downside compared to temp tables is that no statistics and no indexes other than the primary key can be created.… – ghoerz Apr 3 '12 at 15:22
Yes, they can be paged out.. at which point you should know your database well enough to avoid it :) – adaptr Apr 3 '12 at 15:27
Table variables aren't in memory structures. They are physical objects that are flushed to disk just like any other temp table in the tempdb database. They are different because they have no stats, can't have indexes other than the primary key, etc. – mrdenny Apr 3 '12 at 23:06
The usual MS behavior is implicit transactions OFF and READ COMMITTED. So, I think that is a red herring. If you are reading (or writing) a lot of data from (to) tempdb, the underlying files may simply be on faster storage. If you are only dealing with a small number of rows, differences between temporary tables and table variables seem to be highly variable between specific situations (data types, size, recompilation or not, even different servers). IOW, sometimes table variables are faster than temp tables and sometimes table variables are slower than temp tables. YMMV, test to be sure. – darin strait Apr 4 '12 at 15:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.