zoukankan      html  css  js  c++  java
  • [摘]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

    原来是打开了审计功能。

  • 相关阅读:
    OSGI简介
    公司僵尸帐号引发了一系列的入侵事件-细说密码强度验证的重要性
    为其他对象提供一种代理以控制对这个对象的访问-代理模式
    运用共享技术有效地支持大量细粒度的对象-享元模式
    移动APP为什么要开发两套Android和IOS-桥接模式
    非法疫苗引发的思考 -外观模式
    你们还记得张江男、张江女两张图片吗?-装饰模式
    一个程序员的蜕变(我是如何成为架构师的)
    公司新加了一台友宝自动售货机引发的思考-适配器模式
    程序员如何应对北上广高房价示例解说-建造者模式
  • 原文地址:https://www.cnblogs.com/killkill/p/1733878.html
Copyright © 2011-2022 走看看