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.

143<br />

Chapter 4: Transactions<br />

time on our <strong>SQL</strong> instances as a result of sorting and hashing intermediate results sets<br />

before returning them to an end-user.<br />

An alternative way to eliminate the worktables would be to add a predicate to the name<br />

column, as the code snippet in Listing 4.12 demonstrates.<br />

…<br />

FROM sys.dm_tran_active_transactions DTAT<br />

WHERE DTAT.name 'worktable'<br />

ORDER BY DTAT.transaction_begin_time<br />

Listing 4.12: Eliminating worktables from the results returned by active_transactions.<br />

While information regarding the transaction start time, type and the current state of the<br />

transaction may be valuable, it is rare to query this DMV in isolation, as it provides an<br />

incomplete picture of transactional activity. We cannot tell, for example, the databases on<br />

which these transactions are running, the sessions or users that are running them, or the<br />

statements that comprise each transaction. To retrieve this information, we'll need to join<br />

DMVs via the transaction_id column, as will be demonstrated shortly.<br />

sys.dm_tran_database_transactions<br />

The sys.dm_tran_database_transactions DMV is server-scoped (the name is<br />

deceptive) and provides detailed information about the transactions occurring on your<br />

<strong>SQL</strong> <strong>Server</strong> instance. Like the sys.dm_db_tran_active_transactions view, it provides<br />

point-in-time snapshot data, so the results may vary each time the view is queried.<br />

A cursory glance at the available columns may lead one to assume that the data returned<br />

will be similar to that provided by the sys.dm_tran_active_transactions view.<br />

In fact, however, sys.dm_tran_database_transactions provides a much<br />

more granular level of detail about each transaction and gives "physical presence" to a<br />

transaction, in that it returns information about how it is using the transaction log file.

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

Saved successfully!

Ooh no, something went wrong!