Interesting SQL IO information

I was fine tuning a Script Batch and wondered abt the different results been given out by profiler,Statistics io and Sysprocess...I was in utter choas (which I luv at times as that choas leads me to truth ).

I digged in and found following document which explains why they summarize results on READ/WRITES differently...A very interesting scenerio http://support.microsoft.com/?id=314648 or for you reading here it is

There are several different places in which SQL Server reports different input/output (IO) related information:

The physical_io column of the sysprocesses system table.

Informational messages returned in a batch when the STATISTICS IO option is enabled.

The Reads or Writes column of relevant events in a SQL Profiler trace.

Each of these counters report slightly different information. Depending on what you are want to measure, a given counter may be more appropriate to use than another. This article describes what each counter measures so that you can use the information appropriately.

MORE INFORMATION

Each SQL Server connection has an associated process status structure (PSS) that maintains connection-specific state information. Each unique server process ID (SPID) in the sysprocesses system table represents a different PSS, and the information in the sysprocesses virtual table is a "view" into this status information.

SQL Server distinguishes between physical IO (that is, the number of times that SQL Server actually makes a Win32 system call to read or write a page) and a logical IO (any time SQL Server requests access to a page). The higher-level query processor routines in SQL Server use a mechanism to request logical access to a page. This routine searches to see if the page is already in cache, and if so, provides access to that buffer; if the page is not in cache, the routine is responsible for requesting a physical IO and waiting on the IO to complete before providing access.

For each connection, SQL Server maintains counters to track the number of physical reads and physical writes. Any time SQL Server requests a physical read or write as part of servicing work for your connection, the appropriate physical IO counter within the PSS increments. The physical_io column of sysprocesses reports the sum of these two physical IO counters.

If STATISTICS IO is enabled for a connection, SQL Server allocates an array during query execution to track IO information on a per-table basis. As SQL Server processes the query, it records each logical request for a page in the appropriate table's entry in this array, along with whether that logical IO request resulted in a physical IO. SQL Server returns the information, at the end of the query, in error message 3615:

Table 'authors'. Scan count 1, logical reads 2, physical reads 0, read-ahead reads 0.
Table 'titles'. Scan count 1, logical reads 2, physical reads 2, read-ahead reads 0. SQL Profiler reports the number of logical reads and physical writes performed in processing the statement or batch. Note that the Microsoft SQL Server 7.0 documentation regarding these counters contains contradictory information.

In comparing the numbers reported by SQL Profiler with those from STATISTICS IO, it is important to note that logical and physical IOs may be incurred doing work that is related to your query or batch but not specific to the query itself. For example:

During compilation and optimization, there are reads of system tables to obtain information about the table's schema.

There may be access to system tables to check permissions on objects at execution time.

If you execute a stored procedure and SQL Server does not find it in the cache, SQL Server may perform reads to load the text of the procedure from the syscomments system table.

If your query causes an error, IOs take place as SQL Server reads the error text from the sysmessages system table.

There may be IOs on worktables not reported in STATISTICS IO, and so forth.

As a result, in general, the logical reads reported by SQL Profiler do not match up with the sum of those reported by STATISTICS IO. However, the number reported for reads in SQL Profiler should always be equal to or greater than the STATISTICS IO values.

Print | posted @ Friday, July 30, 2004 4:47 AM

Comments on this entry:

Gravatar # Lesbian Voyeur Movies
by Destiny at 6/8/2009 7:10 AM

Give please. You don't get anything clean without getting something else dirty. Help me! There is an urgent need for sites: Lesbian Voyeur Movies. I found only this - lesbian teen hunter. Experience naughty asian lesbian couples having fun licking and kissing each other. Own gay and lesbian tv series on dvd. Thanks ;-). Destiny from Oman.
Gravatar # Ornamental iron corbels
by Narda at 10/14/2009 3:58 PM

Good afternoon. Patriotism is your conviction that this country is superior to all other countries because you were born in it. Help me! It has to find sites on the: Ornamental iron corbels. I found only this - Corbels iron. architecture of a creative floor here used here in the bridge of italy, seats of france and in the iberian peninsula in the romanesque state and widely to the later shape of the abbey of cluny. A wonderful gable-ended area for facing the sales? We showed generally and particularly on it and i very wanted him to have a sink supported out and save me a restricted week from the organ with a late wing road. With best wishes :-), Narda from Fiji.
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: