Solved

what constitutes a read?

Posted on 2012-04-03
7
214 Views
Last Modified: 2012-04-06
is one select statement = one read
(referring to
sys.dm_io_virtual_file_stats.num_of_reads)
0
Comment
Question by:25112
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 23

Assisted Solution

by:wdosanjos
wdosanjos earned 200 total points
Comment Utility
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
 
LVL 5

Author Comment

by:25112
Comment Utility
>>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
 
LVL 23

Assisted Solution

by:wdosanjos
wdosanjos earned 200 total points
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 69

Assisted Solution

by:ScottPletcher
ScottPletcher earned 200 total points
Comment Utility
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
 
LVL 5

Author Comment

by:25112
Comment Utility
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
 
LVL 19

Accepted Solution

by:
Rimvis earned 100 total points
Comment Utility
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
 
LVL 69

Assisted Solution

by:ScottPletcher
ScottPletcher earned 200 total points
Comment Utility
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

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now