SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Process not releasing tempdb space


Process not releasing tempdb space

Author
Message
curious_sqldba
curious_sqldba
SSCertifiable
SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)

Group: General Forum Members
Points: 7302 Visits: 3696
Any suggestions on how to check why tempdb space is NOT being released?
Vegard Hagen
Vegard Hagen
SSC Eights!
SSC Eights! (907 reputation)SSC Eights! (907 reputation)SSC Eights! (907 reputation)SSC Eights! (907 reputation)SSC Eights! (907 reputation)SSC Eights! (907 reputation)SSC Eights! (907 reputation)SSC Eights! (907 reputation)

Group: General Forum Members
Points: 907 Visits: 387
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)


curious_sqldba
curious_sqldba
SSCertifiable
SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)

Group: General Forum Members
Points: 7302 Visits: 3696
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?
SQLRNNR
SQLRNNR
SSC Guru
SSC Guru (65K reputation)SSC Guru (65K reputation)SSC Guru (65K reputation)SSC Guru (65K reputation)SSC Guru (65K reputation)SSC Guru (65K reputation)SSC Guru (65K reputation)SSC Guru (65K reputation)

Group: General Forum Members
Points: 65977 Visits: 18570
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

curious_sqldba
curious_sqldba
SSCertifiable
SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)

Group: General Forum Members
Points: 7302 Visits: 3696
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
SQLRNNR
SQLRNNR
SSC Guru
SSC Guru (65K reputation)SSC Guru (65K reputation)SSC Guru (65K reputation)SSC Guru (65K reputation)SSC Guru (65K reputation)SSC Guru (65K reputation)SSC Guru (65K reputation)SSC Guru (65K reputation)

Group: General Forum Members
Points: 65977 Visits: 18570
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

Noetic DBA
Noetic DBA
Mr or Mrs. 500
Mr or Mrs. 500 (539 reputation)Mr or Mrs. 500 (539 reputation)Mr or Mrs. 500 (539 reputation)Mr or Mrs. 500 (539 reputation)Mr or Mrs. 500 (539 reputation)Mr or Mrs. 500 (539 reputation)Mr or Mrs. 500 (539 reputation)Mr or Mrs. 500 (539 reputation)

Group: General Forum Members
Points: 539 Visits: 422
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;
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search