Quantcast
Channel: SQL Server Database Engine forum
Viewing all articles
Browse latest Browse all 12963

How to determine which objects/queries are main cause for unusual increase in tempDB

$
0
0

Hi,

From past 2 days, tempdb is growing unexpectedly and completely filling up the Drive. Currently we are restarting the service.

Yesterday, when we ran the below query when tempDB was full, we got 2 queries. But those 2 queries were running since long time and we are surprised how suddenly those queries are responsible for tempDB growth

select top 10
t1.session_id,
t1.request_id,
t1.task_alloc,
     t1.task_dealloc, 
    (SELECT SUBSTRING(text, t2.statement_start_offset/2 + 1,
          (CASE WHEN statement_end_offset = -1
              THEN LEN(CONVERT(nvarchar(max),text)) * 2
                   ELSE statement_end_offset
              END - t2.statement_start_offset)/2)
     FROM sys.dm_exec_sql_text(sql_handle)) AS query_text,
(SELECT query_plan from sys.dm_exec_query_plan(t2.plan_handle)) as query_plan

from      (Select session_id, request_id,
sum(internal_objects_alloc_page_count +   user_objects_alloc_page_count) as task_alloc,
sum (internal_objects_dealloc_page_count + user_objects_dealloc_page_count) as task_dealloc
       from sys.dm_db_task_space_usage
       group by session_id, request_id) as t1,
       sys.dm_exec_requests as t2
where t1.session_id = t2.session_id and
(t1.request_id = t2.request_id) 
     -- and t1.session_id > 50
order by t1.task_alloc DESC

And today, periodically when I was trying to see the tables in "Temporary Tables" in tempdb, I am gettiing TimeOut Period.

Also, after referring below link, I have executed some queries

http://msdn.microsoft.com/en-us/library/ms176029.aspx

--1.Determining the Total Amount of Space 
SELECT SUM(size)*1.0/128 AS [size in MB]
FROM tempdb.sys.database_files
--63478.375000


--2. Determining the Amount Space Used by the Version Store
SELECT SUM(version_store_reserved_page_count) AS [version store pages used],
(SUM(version_store_reserved_page_count)*1.0/128) AS [version store space in MB]
FROM sys.dm_db_file_space_usage;
--176.875000 MB

--3.Determining the Amount of Space Used by Internal Objects
SELECT SUM(internal_object_reserved_page_count) AS [internal object pages used],
(SUM(internal_object_reserved_page_count)*1.0/128) AS [internal object space in MB]
FROM sys.dm_db_file_space_usage;
--0.625000 MB

--4. Determining the Amount of Space Used by User Objects
SELECT SUM(user_object_reserved_page_count) AS [user object pages used],
(SUM(user_object_reserved_page_count)*1.0/128) AS [user object space in MB]
FROM sys.dm_db_file_space_usage;
--1.500000

If we see the above query, total space occupied by tempDB is 63 GB. 

When I tried to see what are the objects making this total of 63 GB(Query 2, 3, 4) they do not sum up to 63 GB.

How can I know what is causing the tempDB to 63 GB and how can I check what is the root cause for this unexepected increase in the tempDB growth

NOTE: Last week, RAM has been increased by 8 GB and  2 processors were added.


Raksha


Viewing all articles
Browse latest Browse all 12963

Trending Articles