Skip to content

Commit 76fffc9

Browse files
Update AzureTempDB_SpaceMonitoring.txt
Added query to get "Drill down to get information about log consumers"
1 parent a31c77f commit 76fffc9

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

AzureTempDB_SpaceMonitoring.txt

+32
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,38 @@ from sys.dm_os_performance_counters
7171
where counter_name in('Log File(s) Size (KB)','Log File(s) Used Size (KB)')
7272
and instance_name='tempdb'
7373

74+
-- Drill down to get information about log consumers
75+
select
76+
SS.session_id,
77+
SS.host_name,
78+
SS.program_name,
79+
SS.login_name,
80+
DBT.transaction_id,
81+
DBT.database_transaction_begin_time,
82+
database_transaction_type_desc = case DBT.database_transaction_type
83+
when 1 then 'Read/write transaction'
84+
when 2 then 'Read-only transaction'
85+
when 3 then 'System transaction'
86+
end,
87+
database_transaction_state_desc = case DBT.database_transaction_state
88+
when 1 then 'The transaction has not been initialized'
89+
when 3 then 'The transaction has been initialized but has not generated any log records'
90+
when 4 then 'The transaction has generated log records'
91+
when 5 then 'The transaction has been prepared'
92+
when 10 then 'The transaction has been committed'
93+
when 11 then 'The transaction has been rolled back'
94+
when 12 then 'The transaction is being committed. (The log record is being generated, but has not been materialized or persisted.'
95+
end,
96+
SST.open_transaction_count,
97+
TotalLogSpaceReserved = format(1.0*(DBT.database_transaction_log_bytes_reserved+DBT.database_transaction_log_bytes_reserved_system)/1024/1024,'#,##0'),
98+
database_transaction_log_bytes_used_MB = format(1.0*DBT.database_transaction_log_bytes_used/1024/1024,'#,##0'),
99+
database_transaction_log_bytes_reserved_MB = format(1.0*DBT.database_transaction_log_bytes_reserved/1024/1024,'#,##0'),
100+
database_transaction_log_bytes_used_system_MB = format(1.0*DBT.database_transaction_log_bytes_used_system/1024/1024,'#,##0'),
101+
database_transaction_log_bytes_reserved_system_MB = format(1.0*DBT.database_transaction_log_bytes_reserved_system/1024/1024,'#,##0')
102+
From sys.dm_tran_database_transactions DBT
103+
join sys.dm_tran_session_transactions SST on DBT.transaction_id = SST.transaction_id
104+
join sys.dm_exec_sessions SS on SS.session_id = SST.session_id
105+
74106

75107

76108
-- another option to monitor TemoDB usage is by using Adam Machanic WhoIsActive stored procedure.

0 commit comments

Comments
 (0)