I restarted SQL Server 2005 and ran a query with statistics IO on.
I got these results: Table 'xxx'. Scan count 1, logical reads 789, physical reads 3, read-ahead reads 794, ...
read-ahead reads is the number of pages read and placed in the cache. Shouldn't then the physical reads at least be the same number?
Also because it's a first run for the query, shouldn't logical reads be 0? Or is SQL Server reading the pages physically, putting them in the cache and then reading from the cache? Why is there a count for logical reads when the cache should be empty?
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.
The physical reads Oracle metric is the total number of data blocks read from disk. This equals the number of "physical reads direct" plus all reads into buffer cache. Other notes on physical reads includes: Oracle Physical Reads Segment Statistics.
When a block is requested by a query, Oracle looks for it in the Buffer Cache and if found, it results in a Logical read and if it does not find the Block in there it results in a physical read (disk I/O).
So indexes are great for reducing reads because they allow us to store only the data that is needed for a specific query (both as key columns and included columns). Fewer columns = greater density = fewer reads necessary.
All reads are logical reads.
Some also incur physical reads and read ahead reads in addition to bring pages into cache.
Presumably it read ahead a few pages that were never actually required by your query hence the fact that this number is slightly larger than the actual logical reads.
The docs from MS say that "Read-Ahead Reads" are reading pages into the cache. That's not very helpful... one would assume that "Physical Reads" also place their resulting page into the cache.
My re-wording of what MS is saying is:
I can't find them saying that anywhere, but read-ahead would be pointless if that's not what they were really trying to say.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With