行欲取導致sqlplus中trace的consistent gets远大于实际块数

SQL*Plus: Release 10.2.0.4.0 - Production on Thu Nov 10 15:09:11 2011Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining Scoring Engine
and Real Application Testing options

SQL> SELECT BYTES/1024/1024 SIZE_MB FROM DBA_SEGMENTS
  2  WHERE SEGMENT_NAME='SYS_USER' AND WNER='JESSE';

   SIZE_MB
----------
        56

SQL> alter system flush buffer_cache;

System altered.

SQL> set autotrace traceonly;
SQL> select * from JESSE.SYS_USER;

253348 rows selected.


Execution Plan
----------------------------------------------------------
Plan hash value: 4234589240

------------------------------------------------------------------------------
| Id  | Operation         | Name     | Rows  | Bytes | Cost (%CPU)| Time     |
------------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |          |   253K|    50M|  1192   (1)| 00:00:17 |
|   1 |  TABLE ACCESS FULL| SYS_USER |   253K|    50M|  1192   (1)| 00:00:17 |
------------------------------------------------------------------------------
Statistics
----------------------------------------------------------
          0  recursive calls
          0  db block gets
      20272  consistent gets
       3524  physical reads
          0  redo size
   31335655  bytes sent via SQL*Net to client
     186271  bytes received via SQL*Net from client
      16891  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
     253348  rows processed

數據庫的db_block_size=16k,表SYS_USER的包含數據塊數=表總大小/db_block_size=56MB/16KB=3584同上面的physical reads基本相等,但consistent gets的數量和我預計的3584相差太大,在這個庫從來不會對SYS_USER表數據做修改,在一致性讀的時候也不會獲取回滾段的數據。

原來遇到過這樣問題沒仔細研究,剛查詢資料發現Tom大師曾經對此做過解答:

sqlplus的欲取行默認是arraysize 15,一次只能查15行,行數/每讀取行數=253348/15(sqlplus中查詢完起碼要讀這么多數據庫塊,即便是有重復的)+3584=20473和上面consistent gets的數量基本相等了。

再驗證一下,將arraysize盡量設大,看看有變化沒有:

SQL> SET ARRAYSIZE 50000;
SP2-0267: arraysize option 50000 out of range (1 through 5000)
SQL> SET ARRAYSIZE 5000;
SQL> select * from JESSE.SYS_USER;

253348 rows selected.


Execution Plan
----------------------------------------------------------
Plan hash value: 4234589240

------------------------------------------------------------------------------
| Id  | Operation         | Name     | Rows  | Bytes | Cost (%CPU)| Time     |
------------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |          |   253K|    50M|  1192   (1)| 00:00:17 |
|   1 |  TABLE ACCESS FULL| SYS_USER |   253K|    50M|  1192   (1)| 00:00:17 |
------------------------------------------------------------------------------
Statistics
----------------------------------------------------------
          0  recursive calls
          0  db block gets
       3582  consistent gets
          0  physical reads
          0  redo size
   28254118  bytes sent via SQL*Net to client
       1042  bytes received via SQL*Net from client
         52  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
     253348  rows processed

果不其然,看來以后用sqlplus做trace要小心啦。。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/25583515/viewspace-710763/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/25583515/viewspace-710763/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值