sql走索引为什么始终有物理读


 问题是这样的:

  1 sql> r

  2   1  select count(*)

  3   2  from t_edu_member_info

  4   3* where status='1' and xs_zy='1'

  01 执行计划

  02 -------------------------------------------------------------------------------------------

  03    0      SELECT STATEMENT Optimizer=ALL_ROWS (Cost=1 Card=1 Bytes=10)

  04    1    0   SORT (AGGREGATE)

  05    2    1     FILTER

  06    3    2       INDEX (RANGE SCAN) OF 'IND_T_PREBM4' (NON-UNIQUE) (Cost=1 Card=5 Bytes=50)

  07

  08 统计信息

  09 ----------------------------------------------------------

  10          25  recursive calls

  11          14  db block gets

  12           3  consistent gets

  13           1  physical reads

  14         972  redo size

  15         375  bytes sent via SQL*Net to client

  16         372  bytes received via SQL*Net from client

  17           2  SQL*Net roundtrips to/from client

  18           1  sorts (memory)

  19           0  sorts (disk)

  20           1  rows processed

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

  1 select count(*)

  2 from t_edu_member_info

  3 where status='1'

  4 and xs_zy='1'

  01 call     count       cpu    elapsed       disk      query    current        rows

  02 ------- ------  -------- ---------- ---------- ---------- ----------  ----------

  03 Parse        1      0.01       0.00          0          0          0           0

  04 Execute      1      0.78       0.90          0          0         12           0

  05 Fetch        2      0.00       0.00          0          1          0           1

  06 ------- ------  -------- ---------- ---------- ---------- ----------  ----------

  07 total        4      0.79       0.90          0          1         12           1

  08

  09 Misses in library cache during parse: 1

  10 Optimizer mode: ALL_ROWS

  11 Parsing user id: 64

  12

  13 Rows     Row Source Operation

  14 -------  ---------------------------------------------------

  15       1  SORT AGGREGATE

  16       0   FILTER

  17       0    INDEX RANGE SCAN IND_T_PREBM4 (object id 38674)

  18

  19 Elapsed times include waiting on following events:

  20   Event waited on                             Times   Max. Wait  Total Waited

  21   ----------------------------------------   Waited  ----------  ------------

  22   direct path write                               1        0.00          0.00

  23   SQL*Net message to client                       2        0.00          0.00

  24   SQL*Net message from client                     2       27.20         27.22

  1 insert into sys.fga_log$(sessionid,timestamp#,dbuid,osuid,obj$schema,obj$name,

  2   policyname,scn,plhol,sqlbind,oshst,clientid,extid,lsqltext)

  3 values

  4  (:1,sysdate,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11,:12,:13)

  01 call     count       cpu    elapsed       disk      query    current        rows

  02 ------- ------  -------- ---------- ---------- ---------- ----------  ----------

  03 Parse        1      0.00       0.00          0          0          0           0

  04 Execute      1      2.09       2.94          1          2          2           1

  05 Fetch        0      0.00       0.00          0          0          0           0

  06 ------- ------  -------- ---------- ---------- ---------- ----------  ----------

  07 total        2      2.09       2.94          1          2          2           1

  08

  09 Misses in library cache during parse: 1

  10 Optimizer mode: CHOOSE

  11 Parsing user id: SYS   (recursive depth: 1)

  12

  13 Elapsed times include waiting on following events:

  14   Event waited on                             Times   Max. Wait  Total Waited

  15   ----------------------------------------   Waited  ----------  ------------

  16   direct path read (lob)                          1        0.00          0.00

  原来是打开了审计功能


« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3