[摘]sql走索引,怎么始终有物理读?

原文连接是:sql走索引,怎么始终有物理读?

问题是这样的:

sql> r
  1  select count(*)
  2  from t_edu_member_info
  3* where status='1' and xs_zy='1'
执行计划
-------------------------------------------------------------------------------------------
   0      SELECT STATEMENT Optimizer=ALL_ROWS (Cost=1 Card=1 Bytes=10)
   1    0   SORT (AGGREGATE)
   2    1     FILTER
   3    2       INDEX (RANGE SCAN) OF 'IND_T_PREBM4' (NON-UNIQUE) (Cost=1 Card=5 Bytes=50)

统计信息
----------------------------------------------------------
         25  recursive calls
         14  db block gets
          3  consistent gets
          1  physical reads
        972  redo size
        375  bytes sent via SQL*Net to client
        372  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          1  sorts (memory)
          0  sorts (disk)
          1  rows processed

这个结果已经跑了几次,但是 recursive calls 依然存在,后来从10046事件产生的trace文件中到了线索。用tkprof格式化trace文件后,可以看到:

select count(*)
from t_edu_member_info
where status='1'
and xs_zy='1'
call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.00          0          0          0           0
Execute      1      0.78       0.90          0          0         12           0
Fetch        2      0.00       0.00          0          1          0           1
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        4      0.79       0.90          0          1         12           1

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 64  

Rows     Row Source Operation
-------  ---------------------------------------------------
      1  SORT AGGREGATE 
      0   FILTER  
      0    INDEX RANGE SCAN IND_T_PREBM4 (object id 38674)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  direct path write                               1        0.00          0.00
  SQL*Net message to client                       2        0.00          0.00
  SQL*Net message from client                     2       27.20         27.22
insert into sys.fga_log$(sessionid,timestamp#,dbuid,osuid,obj$schema,obj$name,
  policyname,scn,plhol,sqlbind,oshst,clientid,extid,lsqltext) 
values
 (:1,sysdate,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11,:12,:13) 
call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.00          0          0          0           0
Execute      1      2.09       2.94          1          2          2           1
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2      2.09       2.94          1          2          2           1

Misses in library cache during parse: 1
Optimizer mode: CHOOSE
Parsing user id: SYS   (recursive depth: 1)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  direct path read (lob)                          1        0.00          0.00

原来是打开了审计功能。

posted @ 2010-05-12 17:37  killkill  阅读(532)  评论(1编辑  收藏  举报