Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server 2005- Investigate what caused tempdb to grow huge

The tempdb of my instance grew huge eating up all the available disk space and causing applications to go down. Had to restart the instance in emergency. However, I want to investigate and dig deep as to what caused the temp db to grow huge all of sudden. What were the queries, processes that casued this? Can someone help me to pull the required info. I know I wont get much of historical Data from the SQL serevr. I do have the Idera SQL Diagnostic Manager(third party tool) deployed. Any help to use the tool would be really appreciated.

like image 380
AK2 Avatar asked Feb 28 '13 08:02

AK2


3 Answers

As for postmortem analysis, you can use the tools already installed on your server. For future proactive analysis, you can use SQL traces directly in SQL Profiler, or query the traces using SQL statements.

sys.fn_trace_gettable

sys.trace_events

You can also use an auditing tool that tracks every event that happened on a SQL Server instance and databases, such as ApexSQL Comply. It also uses SQL traces, configures them automatically,and processes captured information. It tracks object and data access and changes, failed and successful logins, security changes, etc. ApexSQL Comply loads all captured information into a centralized repository.

enter image description here

like image 92
Milena Petrovic Avatar answered Dec 04 '22 22:12

Milena Petrovic


There are several reasons that might cause your tempdb to get very big.

A lot of sorting – if this requires more memory than your sql server has then it will store all temp results in tempdb

DBCC commands – if you’re frequently running commands such as DBCC CheckDB this might be the cause. These functions store its results in temp db

Very large resultsets – these are also using temp db to run properly

A lot of heavy transactions such as bulk inserts

Check out this article for more details http://msdn.microsoft.com/en-us/library/ms176029.aspx on how to troubleshoot this.

like image 45
Ken Williams Avatar answered Dec 04 '22 22:12

Ken Williams


AK2, We have Idera DM tool as well. If you know the time frame around what time your tempdb was used heavily you can go to History on the Idera tool to see what query was running at that time and what lead to the server to hose... On the "Tempdb Space used OverTime" you would usually see a straight line or a graph but at the time of heavy use of tempdb there's a pike and a straight drop. Referring to this time-frame you can check into Sessions>Details too see the exact query and who was running the query.

In our server this happens usually when there is a long query doing lots of join. or when there is an expensive query involving in dumping into temp table / table variable. Hope this will help.

like image 29
SdMan Avatar answered Dec 04 '22 23:12

SdMan