加入收藏 | 设为首页 | 会员中心 | 我要投稿 湖南网 (https://www.hunanwang.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程 > 正文

sql-server – 执行打算与STATISTICS IO订单

发布时间:2021-05-23 06:17:08 所属栏目:编程 来源:网络整理
导读:SQL Server图形执行打算从右到左,从上到下阅读. SET STATISTICS IO ON天生的输出是否故意义的次序? 以下查询: SET STATISTICS IO ON;SELECT *FROM Sales.SalesOrderHeader AS soh JOIN Sales.SalesOrderDetail AS sod ON soh.SalesOrderID = sod.SalesOrder

SQL Server图形执行打算从右到左,从上到下阅读. SET STATISTICS IO ON天生的输出是否故意义的次序?

以下查询:

SET STATISTICS IO ON;

SELECT  *
FROM    Sales.SalesOrderHeader AS soh
        JOIN Sales.SalesOrderDetail AS sod ON soh.SalesOrderID = sod.SalesOrderID
        JOIN Production.Product AS p ON sod.ProductID = p.ProductID;

天生此打算:

而这个STATISTICS IO输出:

Table 'Worktable'. Scan count 0,logical reads 0,physical reads 0,read-ahead reads 0,lob logical reads 0,lob physical reads 0,lob read-ahead reads 0.
Table 'SalesOrderDetail'. Scan count 1,logical reads 1246,physical reads 3,read-ahead reads 1277,lob read-ahead reads 0.
Table 'SalesOrderHeader'. Scan count 1,logical reads 689,physical reads 1,read-ahead reads 685,lob read-ahead reads 0.
Table 'Product'. Scan count 1,logical reads 15,read-ahead reads 14,lob read-ahead reads 0.

以是,我重申一下:是什么给出的?对STATISTICS IO输出有一个故意义的排序照旧行使了一些恣意次序?

办理要领

我最初玩各类查询表白基础没有模式,可是在亲近存眷时,它好像可以猜测持续打算.我最终在 KB314648 @AustinZellner提到:

Each SQL Server connection has an associated process status structure
(PSS) that maintains connection-specific state information. Each
unique server process ID (SPID) in the sysprocesses system table
represents a different PSS,and the information in the sysprocesses
virtual table is a “view” into this status information.

以及与您的题目相干的部门:

If STATISTICS IO is enabled for a connection,SQL Server allocates an
array during query execution to track IO information on a per-table
basis. As SQL Server processes the query,it records each logical
request for a page in the appropriate table’s entry in this array,
along with whether that logical IO request resulted in a physical IO.
SQL Server returns the information,at the end of the query,in error
message 3615.

调查到的举动表白,凭证天生IO的次序对数组举办了条目,这现实上是物理运算符上GetNext()的功效.统计信息输出中的最后一个条目是导致记录IO的第一个表,第一个条目是最后一个表.我展望并行打算的次序是不行猜测的(可能更少),由于不能担保起首布置哪个并利用命.

(编辑:湖南网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读