sql统计io扫描计数解释
很简单的问题,但我在谷歌上没有找到很好的解释。 当使用“设置统计 IO ON”时,逻辑读取和扫描计数将在 Management Studio 的消息窗口中提供。 如果我有:
tblExample,扫描计数 5,逻辑读取 20
扫描计数意味着什么?
Simple question, but I haven't found a good explanation on google. When using Set Statistics IO ON, the logical reads and scan count is provided in the message window of management studio. If I have:
tblExample, scan count 5, logical reads 20
What does scan count signify?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
至于“表扫描”的含义,我能找到的最好的说法是:
换句话说,仅扫描计数本身不足以提供足够的信息来继续。 您需要确切地知道这些扫描是什么——因此您必须查看实际的执行计划以获取更多详细信息。 最重要的是,它本身并不是一个非常有用的指标!
另外:
http://www.eggheadcafe .com/software/aspnet/32171165/set-statistics-io-scan-count-explanation.aspx
As far as what a "table scan" means, the best I could find is this:
In other words, scan count alone by itself is not enough information to proceed. You need to know what those scans were, exactly -- so you'll have to look at the actual execution plan for more detail. Bottom line it's not a very useful metric by itself!
Additionally:
http://www.eggheadcafe.com/software/aspnet/32171165/set-statistics-io-scan-count-explanation.aspx
来自在线图书
扫描计数:
执行的索引或表扫描的数量。
逻辑读取:
从数据缓存读取的页数。
物理读取:
从磁盘读取的页数。
预读:
放入缓存以供查询的页数。
另请参阅此处:http://technet.microsoft.com/en-us/library /ms184361.aspx
From Books On Line
Scan count:
Number of index or table scans performed.
logical reads:
Number of pages read from the data cache.
physical reads:
Number of pages read from disk.
read-ahead reads:
Number of pages placed into the cache for the query.
See also here: http://technet.microsoft.com/en-us/library/ms184361.aspx
如果要继续收集msdn引用。 然后[1]在[2]中重复:
“逻辑读取
该值表示处理查询所需的页面访问总数。 每个页面都是从数据缓存中读取的,无论是否需要将该页面从磁盘放入缓存以进行任何给定的读取。 该值始终至少与物理读取的值一样大,并且通常大于该值。 同一页可以被读取多次(例如,当从索引驱动查询时),因此表的逻辑读取计数可能大于表中的页数。
物理阅读
该值表示从磁盘读取的页数; 它始终小于或等于逻辑读取的值。 性能监视器显示的缓冲区高速缓存命中率值是根据逻辑读取和物理读取值计算得出的,如下所示:
预读读取
Read Ahead Reads 值指示在处理查询时使用预读机制读入缓存的页数。 查询不一定使用这些页面。 如果最终需要一个页面,则计算逻辑读取,但不计算物理读取。 高值意味着物理读取的值可能较低,并且缓存命中率可能高于... [由 vgv8 截断]
扫描计数
Scan Count 值表示相应表被访问的次数。 嵌套循环连接的外部表的扫描计数为 1。对于内部表,扫描计数可能是“通过循环”访问表的次数。 逻辑读取的数量由扫描计数乘以每次扫描访问的页数之和确定。 但是,即使对于嵌套循环联接,内表的扫描计数也可能显示为 1。SQL Server 可能会将所需的行从内表复制到缓存中的工作表中,并使用该工作表访问实际数据行。 当计划中使用此步骤时,STATISTICS IO 输出中通常没有任何指示。 您必须使用 STATISTIC TIME 的输出以及有关所使用的实际处理计划的信息来确定执行查询所涉及的实际工作。 哈希联接和合并联接通常将联接中涉及的两个表的扫描计数显示为 1,但这些类型的联接可能需要更多的内存。 您可以在执行查询时检查 sysprocesses 中的 memusage 值,但与physical_io 值不同,这不是累积计数器,仅对当前运行的查询有效。 一旦查询完成,就无法查看它使用了多少内存。”
[1]
第 4 章查询性能故障排除。 监控查询性能
Microsoft® SQL Server™ 2005 内部:查询调优和优化
作者:Kalen Delaney
出版商:Microsoft Press
发布日期:2007 年 9 月 26 日
打印 ISBN-10:0-7356-2196-9
打印 ISBN-13:978-0-7356-2196-1
页数:448
[2]
监控查询性能
优化查询性能
作者:罗恩·索库普、卡伦·德莱尼
《Inside Microsoft SQL Server 7.0》第 14 章,由 Microsoft Press 出版
http://technet.microsoft.com/en-us/library/cc917719.aspx#ECAA< /a>
If to continue to collect msdn citations. Then [1] which is repeated in [2]:
"Logical Reads
This value indicates the total number of page accesses needed to process the query. Every page is read from the data cache, whether or not it was necessary to bring that page from disk into the cache for any given read. This value is always at least as large and usually larger than the value for Physical Reads. The same page can be read many times (such as when a query is driven from an index), so the count of Logical Reads for a table can be greater than the number of pages in a table.
Physical Reads
This value indicates the number of pages that were read from disk; it is always less than or equal to the value of Logical Reads. The value of the Buffer Cache Hit Ratio, as displayed by Performance Monitor, is computed from the Logical Reads and Physical Reads values as follows:
Read Ahead Reads
The Read Ahead Reads value indicates the number of pages that were read into cache using the read ahead mechanism while the query was processed. These pages are not necessarily used by the query. If a page is ultimately needed, a logical read is counted but a physical read is not. A high value means that the value for Physical Reads is probably lower and the cache-hit ratio is probably higher than... [truncated by vgv8]
Scan Count
The Scan Count value indicates the number of times that the corresponding table was accessed. Outer tables of a nested loop join have a Scan Count of 1. For inner tables, the Scan Count might be the number of times "through the loop" that the table was accessed. The number of Logical Reads is determined by the sum of the Scan Count times the number of pages accessed on each scan. However, even for nested loop joins, the Scan Count for the inner table might show up as 1. SQL Server might copy the needed rows from the inner table into a worktable in cache and use this worktable to access the actual data rows. When this step is used in the plan, there is often no indication of it in the STATISTICS IO output. You must use the output from STATISTIC TIME, as well as information about the actual processing plan used, to determine the actual work involved in executing a query. Hash joins and merge joins usually show the Scan Count as 1 for both tables involved in the join, but these types of joins can involve substantially more memory. You can inspect the memusage value in sysprocesses while the query is being executed, but unlike the physical_io value, this is not a cumulative counter and is valid only for the currently running query. Once a query finishes, there is no way to see how much memory it used."
[1]
Chapter 4. Troubleshooting Query Performance. Monitoring Query Performance
Inside Microsoft® SQL Server™ 2005: Query Tuning and Optimization
by Kalen Delaney
Publisher: Microsoft Press
Pub Date: September 26, 2007
Print ISBN-10: 0-7356-2196-9
Print ISBN-13: 978-0-7356-2196-1
Pages: 448
[2]
Monitoring Query Performance
Optimizing Query Performance
By Ron Soukup, Kalen Delaney
Chapter 14 from Inside Microsoft SQL Server 7.0, published by Microsoft Press
http://technet.microsoft.com/en-us/library/cc917719.aspx#ECAA
这里对此进行了相当全面的总结。
Quite a comprehensive summary of this here.
忽略扫描计数,这并不重要。 重点关注如何降低逻辑读取。 基于 http://www.practicalsqldba.com/2013/07 /sql-server-performance-tuning.html。
Ignore Scan Count, it is not important. Focus on how to lower Logical Reads. Based on http://www.practicalsqldba.com/2013/07/sql-server-performance-tuning.html.