|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Yesterday @ 8:11 PM
Points: 1,172,
Visits: 2,686
|
|
Any suggestions on how to check why tempdb space is NOT being released?
|
|
|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: Sunday, May 12, 2013 11:41 PM
Points: 494,
Visits: 325
|
|
Most likely you've come across a piece of bad application code that doesn't clean up after itself.
All temporary objects created in tempdb must be dropped when you're done with them.
You can check this by running a trace and looking at the actual SQL code. Anything that's created and not dropped at the end of a transaction is part of the problem.
Vegard Hagen Norwegian DBA, blogger and generally a nice guy who believes the world is big enough for all of us.
@vegard_hagen on Twitter Blog: Vegard's corner (No actual SQL stuff here - haven't found my niche yet. Maybe some day...)
"It is better to light a candle than to curse the darkness." (Chinese proverb)
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Yesterday @ 8:11 PM
Points: 1,172,
Visits: 2,686
|
|
Vegard Hagen (10/22/2012) Most likely you've come across a piece of bad application code that doesn't clean up after itself.
All temporary objects created in tempdb must be dropped when you're done with them.
You can check this by running a trace and looking at the actual SQL code. Anything that's created and not dropped at the end of a transaction is part of the problem.
So within a stored procedure, if i am creating any temp tables they should also be dropped? My understanding was temp tables are dropped after the session is completed?
|
|
|
|
|
SSCoach
         
Group: General Forum Members
Last Login: Yesterday @ 1:07 PM
Points: 18,733,
Visits: 12,332
|
|
sqldba_newbie (10/22/2012)
Vegard Hagen (10/22/2012) Most likely you've come across a piece of bad application code that doesn't clean up after itself.
All temporary objects created in tempdb must be dropped when you're done with them.
You can check this by running a trace and looking at the actual SQL code. Anything that's created and not dropped at the end of a transaction is part of the problem.So within a stored procedure, if i am creating any temp tables they should also be dropped? My understanding was temp tables are dropped after the session is completed?
In many cases that is true. Sometimes the temp table will not clean up after the session is closed. It is typically good practice to clean up these objects - it's only an extra line of code.
That said, what do you mean by tempdb space not being released?
Do you mean that tempdb data files and log file are full and the space is not being released internally or do you mean that tempdb is not shrinking and releasing space to the OS?
Jason AKA CirqueDeSQLeil I have given a name to my pain... MCM SQL Server 2008
SQL RNNR
Posting Performance Based Questions - Gail Shaw Posting Data Etiquette - Jeff Moden Hidden RBAR - Jeff Moden VLFs and the Tran Log - Kimberly Tripp
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Yesterday @ 8:11 PM
Points: 1,172,
Visits: 2,686
|
|
SQLRNNR (10/22/2012)
sqldba_newbie (10/22/2012)
Vegard Hagen (10/22/2012) Most likely you've come across a piece of bad application code that doesn't clean up after itself.
All temporary objects created in tempdb must be dropped when you're done with them.
You can check this by running a trace and looking at the actual SQL code. Anything that's created and not dropped at the end of a transaction is part of the problem.So within a stored procedure, if i am creating any temp tables they should also be dropped? My understanding was temp tables are dropped after the session is completed? In many cases that is true. Sometimes the temp table will not clean up after the session is closed. It is typically good practice to clean up these objects - it's only an extra line of code. That said, what do you mean by tempdb space not being released? Do you mean that tempdb data files and log file are full and the space is not being released internally or do you mean that tempdb is not shrinking and releasing space to the OS?
tempdb data files and log file are full and the space is not being released internally
|
|
|
|
|
SSCoach
         
Group: General Forum Members
Last Login: Yesterday @ 1:07 PM
Points: 18,733,
Visits: 12,332
|
|
sqldba_newbie (10/23/2012)
SQLRNNR (10/22/2012)
sqldba_newbie (10/22/2012)
Vegard Hagen (10/22/2012) Most likely you've come across a piece of bad application code that doesn't clean up after itself.
All temporary objects created in tempdb must be dropped when you're done with them.
You can check this by running a trace and looking at the actual SQL code. Anything that's created and not dropped at the end of a transaction is part of the problem.So within a stored procedure, if i am creating any temp tables they should also be dropped? My understanding was temp tables are dropped after the session is completed? In many cases that is true. Sometimes the temp table will not clean up after the session is closed. It is typically good practice to clean up these objects - it's only an extra line of code. That said, what do you mean by tempdb space not being released? Do you mean that tempdb data files and log file are full and the space is not being released internally or do you mean that tempdb is not shrinking and releasing space to the OS? tempdb data files and log file are full and the space is not being released internally
Ok. So you will need to find what long running queries are consuming the space and holding onto the objects in tempdb.
Jason AKA CirqueDeSQLeil I have given a name to my pain... MCM SQL Server 2008
SQL RNNR
Posting Performance Based Questions - Gail Shaw Posting Data Etiquette - Jeff Moden Hidden RBAR - Jeff Moden VLFs and the Tran Log - Kimberly Tripp
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Thursday, May 16, 2013 7:14 AM
Points: 117,
Visits: 184
|
|
I work with several PowerBuilder developers and have the same issue. It is generally an open transaction on the tempdb. Tempdb will usually check point after I kill the open tran. I also use this script to quickly check free space.
use tempdb DBCC OPENTRAN
use tempdb SELECT DB_NAME() AS DbName, name AS FileName, size/128.0 AS CurrentSizeMB, size/128.0 - CAST(FILEPROPERTY(name, 'SpaceUsed') AS INT)/128.0 AS FreeSpaceMB FROM sys.database_files;
|
|
|
|