BUG: There is a decrease in performance when you frequently create and drop temporary tables in SQL Server 2000 (891553)
The information in this article applies to:
- Microsoft SQL Server 2000 Enterprise Edition
- Microsoft SQL Server 2000 Developer Edition
- Microsoft SQL Server 2000 Personal Edition
- Microsoft SQL Server 2000 Standard Edition
- Microsoft SQL Server 2000 Desktop Engine (MSDE)
- Microsoft SQL Server 2000 64 bit (all editions)
Bug #: 472280 (SQL Server 8.0)
SYMPTOMSAssume the following scenario: You try to perform a repeated operation in a single connection in Microsoft SQL Server 2000 by using the following procedure:
- You create a temporary table.
- You run an Insert statement to insert data into the temporary table by using the sp_executesql stored procedure.
- You drop the temporary table.
In this scenario, performance times may steadily increase. Additionally, performance times continue to increase as long as the connection is not dropped. This problem does not occur if you use a permanent table.
Note This problem slows down only the current connection, and it occurs only in the global temporary tables.
WORKAROUNDTo work around this problem, use one of the
following methods:
- Use a TRUNCATE statement instead of a CREATE statement and a DROP
statement.
- Use permanent tables instead of temporary
tables.
- Use an INSERT statement directly instead of calling the
sp_executesql stored procedure.
Note The call to the sp_executesql stored procedure may not be coded in
your application. However, the stored procedure may be added by the underlying database API. For example, the underlying database API may be ADO,
OLE DB, or ODBC. You can use SQL Profiler to determine whether
the sp_executesql stored procedure was sent to the computer that is running SQL Server. - Run the SQL script from an application. When you run the SQL script from an application, you can disconnect and then reconnect more frequently. Or, when you do this, you can wrap your code inside a stored procedure in SQL Server.
STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are
listed in the "Applies to" section.
Modification Type: | Major | Last Reviewed: | 1/26/2005 |
---|
Keywords: | kbtshoot kbbug KB891553 kbAudDeveloper |
---|
|