SQL procedures use Temporary tables instead of table variables

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
14 年 前
I've looked over various SQL procedures that loads products/categories and I've found that most of them use SQL temporary tables. Since table variables are more performant than temporary tables I suggest that you rewrite SQL code in order to perform faster.

Here are some key points that can help us to decide which of two to use:
•If you have less than 100 rows generally use a table variable.  Otherwise use  a temporary table.  This is because SQL Server won't create statistics on table variables.
•If you need to create indexes on it then you must use a temporary table.
•When using temporary tables always create them and create any indexes and then use them.  This will help reduce recompilations.  The impact of this is reduced starting in SQL Server 2005 but it's still a good idea.

Thanks
14 年 前
Thanks for suggestion
14 年 前
Hi,

Is performance really that big an issue on this type of app.
I wonder if the saving in time by using table variables would contribute any more than
1 or 2 percent in overall performance gains, given internet latency etc.

Just wondering if the conversion is worth even considering.

Regards
Steve
14 年 前
Well,
I'm also considering impact on using SQL TempDB since all of tables are created and then dropped after single use. on a web site that have many interrogations this can create a certain "unwanted" traffic. In any case it would have been less resource intense as it is at the moment.
this is my opinion.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.