30.06.2013 Views

Performance Tuning with SQL Server Dynamic Management Views

Performance Tuning with SQL Server Dynamic Management Views

Performance Tuning with SQL Server Dynamic Management Views

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 4: Transactions<br />

WHEN 3 THEN 'Committed'<br />

WHEN 4 THEN 'Aborted'<br />

WHEN 5 THEN 'Recovered'<br />

END AS dtc_state<br />

FROM sys.dm_tran_active_transactions DTAT<br />

INNER JOIN sys.dm_tran_session_transactions DTST<br />

ON DTAT.transaction_id = DTST.transaction_id<br />

WHERE [DTST].[is_user_transaction] = 1<br />

ORDER BY DTAT.transaction_begin_time<br />

Listing 4.11: Querying sys.dm_db_tran_active_transactions.<br />

Notice that we are able to isolate user transactions via a join back to sys.dm_tran_<br />

session_transactions, filtering on the is_user_transaction column. The results<br />

of this query are shown in Figure 4.6.<br />

Figure 4.6: Currently active user transactions.<br />

Had we not filtered out transactions associated <strong>with</strong> system sessions, we'd also have<br />

seen results for hash work being performed in tempdb, similar to the record shown in<br />

Figure 4.7.<br />

Figure 4.7: Worktable transaction records in sys.dm_db_tran_active_transactions.<br />

Queries against sys.dm_tran_active_transactions will often return a great number<br />

of results that look like this, since these worktables are created and destroyed all the<br />

142

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!