【翻译自mos文章】在tkroof 中为什么物理读要比逻辑读要多

本文解释了在Oracle数据库中物理读取次数大于逻辑读取次数的现象及其原因。通常情况下,物理读取应该包含在逻辑读取中。文章通过10046事件跟踪文件揭示了这种现象背后的原因,并指出这主要是由于直接路径读取导致。

 

参考自:

Why Physical Read is greater than Logical Read in Tkprof (文档 ID 211700.1)

PURPOSE 

In some circumstances, you can find that tkprof report shows more physical reads than logical reads, which isn't the current result as the physical reads are normally included in logical reads. 

SCOPE & APPLICATION

This article will be useful for the DBA's and customers who are concerned by the tuning of Requests. 

Why Physical reads are greater than Logical reads


Sometimes, you can find the following content in tkprof report: 

  •  Physical Reads = Disk (total)
  •  Logical Reads = Query (total) + Current (total)

callcountcpuelapseddiskquerycurrentrows
-----------------------------------------------------------------------
Parse10.671.100000
Execute10.000.000000
Fetch2202167.48678.705794412834731741833014
-----------------------------------------------------------------------
total2204168.15679.815794412834731741833014


The 'disk' column is then greater than the 'query' + 'current' columns. This isn't usual. 

To find the root cause of the problem, you must generate a 10046 event trace file level 8 and check for direct read waits in it. 
In 10046 raw trace, you will find " direct path read " and " direct path write " waits like the example below: 

WAIT #1: nam='direct path read' ela= 10076 p1=4 p2=29035 p3=1 

with  P1 = file#P2 = start block#P3 = num blocks

The " direct path read " waits account explains the difference between logical and physical reads. 

In Oracle 9.2 and above, TKProf will print waits associated with each SQL statement in the output file. 

Explanation:

The reason for more physical reads than logical reads is due to the number of direct reads block access. Direct path reads are generally used by Oracle when reading directly into PGA memory (as opposed to into the buffer cache).
 
They may happen on different actions:  


  •  Sort IO on disk.
  •  Read by parallel Query Slaves when scanning is done.
  •  Blocks read by anticipation (readahead).

Such reads are done without loading blocks into the Buffer Cache. They can be single or multiblock reads. 
Utilizing Direct Path Reads in this manner prevents the Oracle Buffer cache from beeing overloaded. 
Oracle uses this optimisation when it considers that its not necessary to share the blocks between different sessions.

References:

Note:32951.1  Tkprof Interpretation 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值