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 1: Using <strong>Dynamic</strong> <strong>Management</strong> Objects<br />

Point-in-time versus cumulative data<br />

We can query data held on the DMOs just as we would any other table, view, or function.<br />

However, always remember that the data returned is "dynamic" in nature. It is collected<br />

from a range of different structures in the database engine and represents, in the main, a<br />

point-in-time "snapshot" of the activity that was occurring on the server at the time the<br />

DMO query was executed.<br />

Sometimes, this is exactly what is required; we have a performance issue right now, and<br />

want to find out what sessions and queries are running, right now, on the server that<br />

could be causing it. Bear in mind, though, that this point-in-time data can, and likely<br />

will, change each time you query it, as the state of the server changes. You should expect<br />

to occasionally see anomalous or non-representative results, and you may need to run a<br />

script many times to get a true picture of activity on your instance.<br />

Also, it is quite difficult to query the data in these point-in-time DMOs in the hope<br />

that the problem will simply "jump out at you." If, for example, you have a performance<br />

problem and you want to check for any "unusual" locking patterns, then it's unlikely<br />

that a "select [columns] from [locking DMV]" will tell you much, unless you're already<br />

very familiar <strong>with</strong> what "normal" locking looks like on your system, and you can therefore<br />

easily spot anomalies.<br />

In other cases, the DMOs are cumulative. In other words, the data in a given column is<br />

cumulative and incremented whenever a certain event occurs. For example, every time<br />

a session waits a period of time for a resource to become available, this is recorded in a<br />

column of the sys.dm _ os _ wait _ stats DMV. When querying such a DMV, you<br />

will be seeing, for instance, the total amount of time spent waiting for various resources,<br />

across all sessions, since <strong>SQL</strong> <strong>Server</strong> was started or restarted. While this will give you a<br />

broad overview of where time has been spent waiting, over a long period, it will make it<br />

hard to see the smaller details. If you want to measure the impact of a certain change to<br />

the database (a new index for example), you'll need to take a baseline measurement, make<br />

the change, and then measure the difference.<br />

26

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

Saved successfully!

Ooh no, something went wrong!