Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Process not releasing tempdb space Expand / Collapse
Author
Message
Posted Monday, October 22, 2012 3:57 PM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 7:49 AM
Points: 1,295, Visits: 2,994

Any suggestions on how to check why tempdb space is NOT being released?
Post #1375763
Posted Monday, October 22, 2012 4:04 PM


Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Friday, April 11, 2014 6:50 AM
Points: 517, Visits: 346
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)

Post #1375767
Posted Monday, October 22, 2012 9:47 PM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 7:49 AM
Points: 1,295, Visits: 2,994
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?
Post #1375813
Posted Monday, October 22, 2012 10:32 PM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Today @ 9:16 AM
Points: 17,966, Visits: 15,971
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, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Post #1375820
Posted Tuesday, October 23, 2012 6:32 PM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 7:49 AM
Points: 1,295, Visits: 2,994
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
Post #1376289
Posted Tuesday, October 23, 2012 8:24 PM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Today @ 9:16 AM
Points: 17,966, Visits: 15,971
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, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Post #1376300
Posted Wednesday, October 24, 2012 3:33 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Yesterday @ 7:48 AM
Points: 395, Visits: 384
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;
Post #1376698
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse