 |
|
Display SQL Server table I/O
SQL Server Tips by Burleson Consulting |
This is one of the many SQL
Server Windows scripts to display table I/O, from the book "High
Performance SQL Server DBA".This SQL
Server 2005 enhancement means the procedures above need to be altered to account
for the iostall column being broken up
into two columns. The temporary table holding the I/O statistical data must be
changed, as does the INSERT statement that inserts file metric info into it and
the final SELECT, which presents the
information.
SQL Server 2005 presents an easy way to drill deeper in
order to retrieve actual object I/O statistical data. The
sys.dm_db_index_operational_stats
function provides good data that helps pinpoint hot objects in various
databases. This function can be used to get data back on: an entire SQL Server
but is not recommended if there are many of databases and objects; a particular
database; or a specific object. There are many columns returned by the
function, but the object_io.sql
query below will give some of the most
interesting statistics that will help reveal the objects under heavy I/O
pressure:
select
object_name = object_name(object_id),
index_id,
partition_number,
range_scans,
singleton_lookups
forwarded_fetches,
lob_fetches,
leaf_inserts
leaf_updates,
leaf_deletes
row_locks,
row_lock_waits,
row_lock_wait_ms,
page_locks,
page_lock_waits,
page_lock_wait_ms,
page_latch_waits
page_latch_wait_ms
from
sys.dm_db_index_operational_stats (db_id(),-1,-1)
where
See
code depot for full script
The above query uses the current database as an example, but
a database name can be fed to the query if the DBA desires to run it outside of
the database for which statistics are desired. Again, this query will help
uncover hub objects in key databases that may benefit from better indexing,
partitioning, reorganization, or relocation to lesser-used physical devices so
response times may be reduced. Special attention must be paid to the
range_scans ,
forwarded_fetches , and
wait time columns.
This is one of the many SQL Server
scripts to display table I/O from the book "High
Performance SQL Server DBA".