what constitutes a read?

is one select statement = one read
(referring to
sys.dm_io_virtual_file_stats.num_of_reads)
LVL 5
25112Asked:
Who is Participating?
 
RimvisConnect With a Mentor Commented:
Hello 25112,

Try this:
SET STATISTICS IO ON
SELECT * FROM PROGRESS_CARD

Open in new window


Check Messages tab in SSMS after select completes
0
 
wdosanjosConnect With a Mentor Commented:
No, num_of_reads refers to the number of read operations on the DB data/log file.  A single SELECT statement can trigger multiple read operations and potentially hit multiple DB files.
0
 
25112Author Commented:
>>A single SELECT statement can trigger multiple
can you give an example of the above?

SELECT * FROM PROGRESS_CARD

will the above always be one read regardless of how many records are returned.?
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
wdosanjosConnect With a Mentor Commented:
It depends how big PROGRESS_CARD is.  If it's a large table it will be spread across multiple blocks on disk, so it will require multiple reads.
0
 
Scott PletcherConnect With a Mentor Senior DBACommented:
Books Online describes that column this way:

"Number of reads issued on the file."

According to blogs I've read by SQL folks, the counts of reads and writes are PHYSICAL actions, not logical ones.  That is, an actual request to the disk I/O subsystem to read a block(s).  [Reads are typically 64K, whereas writes are 12K.]

So, one SELECT would typically take multiple reads.  But it could take none, if the entire table were already in buffers.
0
 
25112Author Commented:
is there a way to test how many reads a select statement takes..

sys.dm_io_virtual_file_stats shows it for all the transactions going on.. how about just a single statement like...
SELECT * FROM PROGRESS_CARD
0
 
Scott PletcherConnect With a Mentor Senior DBACommented:
Yep, that will do it.

If you can stop other activity, then of course you could capture sys.dm_io_virtual_file_stats before and after the SELECT statement and compare them too.

Note that earlier activity on the table CAN affect the results you get.  If the table was read earlier and is still in the buffers, you will see much less reads than you would if the table was not already in the buffers.  

That is, anything that was already read is "saved", so it won't count against you when you re-read it.  But later SQL might have "forgotten" what was read earlier from your table, and have to read the whole table again, thus showing more reads the second time.

On a test/qa system, you could flush the buffers and make sure you counted every read, but that can hurt performance, so it's best not to do it on a prod system.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.