October 6, 2012 at 3:19 pm
Hi All
When using DMV's to assess your SQL instance, what is a read?
For example, when dealing with DMV's like:
sys.dm_exec_query_stats
sys.dm_exec_requests
There are columns like logical_reads, physical_reads etc...
My questions is, is a read when SQL reads one page?
Thanks
October 6, 2012 at 3:39 pm
a logical read is the pages that are read in memory, a physical read is when the page is brought in from disk
-----------------------------------------------------------------------------------------------------------
"Ya can't make an omelette without breaking just a few eggs" π
October 6, 2012 at 8:09 pm
Perry Whittle (10/6/2012)
a logical read is the pages that are read in memory, a physical read is when the page is brought in from disk
Thanks
Does 1 read mean 1 page?
October 7, 2012 at 12:56 am
Yes a read is a page. A logical read may need to initiate a physical read first if the requested page is not in cache.
more info may be found at this link
-----------------------------------------------------------------------------------------------------------
"Ya can't make an omelette without breaking just a few eggs" π
October 8, 2012 at 12:57 pm
I've always gone by Microsoft's explanation:
βThe I/O from an instance of SQL Server is divided into logical and physical I/O. A logical read occurs every time the database engine requests a page from the buffer cache. If the page is not currently in the buffer cache, a physical read is then performed to read the page into the buffer cache. If the page is currently in the cache, no physical read is generated; the buffer cache simply uses the page already in memory.β
Also, keep in mind that when you run a trace it is considered a logical read and not physical.
Physical reads for me have been a pain point when dealing with performance.
October 8, 2012 at 3:02 pm
CYates (10/8/2012)
I've always gone by Microsoft's explanation:...
{snip}
Also, keep in mind that when you run a trace it is considered a logical read and not physical.
Have you got an MS link that explains that as well?
--Jeff Moden
Change is inevitable... Change for the better is not.
October 8, 2012 at 3:05 pm
Never mind. I got it. BOL states:
Reads
The number of read operations on the logical disk that are performed by the server on behalf of the event. These read operations include all reads from tables and buffers during the statement's execution.
In this case, I don't believe that "logical" means just "logical reads". It would appear to include both physical and logic reads for the "logically named disk".
Of course, I could have misinterpreted that. Any one else have something more finite?
--Jeff Moden
Change is inevitable... Change for the better is not.
October 8, 2012 at 3:17 pm
Ah... got it. If found (and immediately forgot to copy the URL for) a post by Microsoft Certified Master Gail Shaw where she explained that SQL Server actually only reads from the "buffer pool" which is all "logical". Reads from the physical disk are always read into the "Buffer Pool". It's the reads from that "Buffer Pool" that SQL Profiler counts.
It would appear that the only way to easily find out if physical reads were actually involved is to SET STATISTICS IO ON before you run the query.
--Jeff Moden
Change is inevitable... Change for the better is not.
October 8, 2012 at 3:28 pm
Jeff Moden (10/8/2012)
CYates (10/8/2012)
I've always gone by Microsoft's explanation:...
{snip}
Also, keep in mind that when you run a trace it is considered a logical read and not physical.
Have you got an MS link that explains that as well?
Yes, the link i posted above π
-----------------------------------------------------------------------------------------------------------
"Ya can't make an omelette without breaking just a few eggs" π
October 8, 2012 at 4:03 pm
Jeff Moden (10/8/2012)
Reads from the physical disk are always read into the "Buffer Pool". It's the reads from that "Buffer Pool" that SQL Profiler counts.
Easiest way to think about it is that all reads are logical. Some of the logical reads may additionally be physical reads (the page required wasn't in the buffer pool)
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
October 8, 2012 at 11:55 pm
GilaMonster (10/8/2012)
Jeff Moden (10/8/2012)
Reads from the physical disk are always read into the "Buffer Pool". It's the reads from that "Buffer Pool" that SQL Profiler counts.Easiest way to think about it is that all reads are logical. Some of the logical reads may additionally be physical reads (the page required wasn't in the buffer pool)
Is it safe to say that when a page is requested and it's not in the buffer pool, 2 reads are happening, 1 Physical(To bring the page into memory) and 1 logical (to read the page in memory)?
Thanks
October 9, 2012 at 12:02 am
SQLSACT (10/8/2012)
Is it safe to say that when a page is requested and it's not in the buffer pool, 2 reads are happening, 1 Physical(To bring the page into memory) and 1 logical (to read the page in memory)?Thanks
Thats exactly what is happening.
The physical read just go grabs the page, the logical read is interested what's on the page.
-----------------------------------------------------------------------------------------------------------
"Ya can't make an omelette without breaking just a few eggs" π
October 9, 2012 at 8:41 am
GilaMonster (10/8/2012)
Jeff Moden (10/8/2012)
Reads from the physical disk are always read into the "Buffer Pool". It's the reads from that "Buffer Pool" that SQL Profiler counts.Easiest way to think about it is that all reads are logical. Some of the logical reads may additionally be physical reads (the page required wasn't in the buffer pool)
Thanks, Gail.
--Jeff Moden
Change is inevitable... Change for the better is not.
October 9, 2012 at 8:44 am
Perry Whittle (10/8/2012)
Jeff Moden (10/8/2012)
CYates (10/8/2012)
I've always gone by Microsoft's explanation:...
{snip}
Also, keep in mind that when you run a trace it is considered a logical read and not physical.
Have you got an MS link that explains that as well?
Yes, the link i posted above π
That's what I get for reading threads without the right amount of caffeine in my system. I totally missed that. Thanks Perry.
The key part on the article from that link is the very first paragraph.
The I/O from an instance of the SQL Server Database Engine includes logical and physical reads. A logical read occurs every time the Database Engine requests a page from the buffer cache. If the page is not currently in the buffer cache, a physical read first copies the page from disk into the cache.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 14 posts - 1 through 13 (of 13 total)
You must be logged in to reply to this topic. Login to reply