Temp tables and performance

  • As far as i read on the net using temp table increase the execution time of the procedure, but my collegue says that he decreased it after he rewrote the procedure using temp tables, which I wrote using derived tables.

  • There is no hard and fast rule. Good coding is usually far more important than the chosen execution method.

    If you're not sure, then try both!

  • You were right robert, we have improved the performance by optimizing the query and using the temp tables. but, can we improve it furthur if we use "Table" variable instead of using temp tables?

  • I can't say for sure since I haven't played with table variables very much, but I'd suspect that they're basically a convenience and that the underlying implementation will not differ much from standard temp tables.

    Best suggestion is to try it and see.

  • Table variables and temp tables are different in their implementation. You can read all about it at:

    http://support.microsoft.com/default.aspx?scid=kb;en-us;305977

  • In some instances adding an index or a clustered index to the #Temp table can greatly enhance perfomance. This is one thing that that #Temp tables have over the other methods, and when appropriately used can have impact.

    Robert is correct in writing "There are no hard & fast rules..."



    Once you understand the BITs, all the pieces come together

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply