Welcome to oracle_awen's archive blog
打开sql跟踪的功能:
SQL> set autotrace traceonly;

执行下面的SQL看计划:
SQL> select * from awen.ob_bak where owner='AWEN';

已选择2304行。


执行计划
----------------------------------------------------------
Plan hash value: 709901947

----------------------------------------------------------------------------------------

| Id  | Operation                   | Name     | Rows  | Bytes | Cost (%CPU)| Time     |

----------------------------------------------------------------------------------------

|   0 | SELECT STATEMENT            |          |   774K|    68M| 27184   (2)| 00:00:33 |

|   1 |  TABLE ACCESS BY INDEX ROWID| OB_BAK   |   774K|    68M| 27184   (2)| 00:00:33 |

|*  2 |   INDEX RANGE SCAN          | OB_INDEX |   774K|       |  1860   (4)| 00:00:03 |

----------------------------------------------------------------------------------------


Predicate Information (identified by operation id):
---------------------------------------------------

   2 - access("OWNER"='AWEN')


统计信息
----------------------------------------------------------
          1  recursive calls
          0  db block gets
       1466  consistent gets
       1258  physical reads
          0  redo size
     220074  bytes sent via SQL*Net to client
       2068  bytes received via SQL*Net from client
        155  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
       2304  rows processed

有1258 次physical reads,再次运行同样的SQL,看执行计划:
SQL> select * from awen.ob_bak where owner='AWEN';

已选择2304行。


执行计划
----------------------------------------------------------
Plan hash value: 709901947

----------------------------------------------------------------------------------------

| Id  | Operation                   | Name     | Rows  | Bytes | Cost (%CPU)| Time     |

----------------------------------------------------------------------------------------

|   0 | SELECT STATEMENT            |          |   774K|    68M| 27184   (2)| 00:00:33 |

|   1 |  TABLE ACCESS BY INDEX ROWID| OB_BAK   |   774K|    68M| 27184   (2)| 00:00:33 |

|*  2 |   INDEX RANGE SCAN          | OB_INDEX |   774K|       |  1860   (4)| 00:00:03 |

----------------------------------------------------------------------------------------


Predicate Information (identified by operation id):
---------------------------------------------------

   2 - access("OWNER"='AWEN')


统计信息
----------------------------------------------------------
          0  recursive calls
          0  db block gets
       1466  consistent gets
          0  physical reads
          0  redo size
     220074  bytes sent via SQL*Net to client
       2068  bytes received via SQL*Net from client
        155  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
       2304  rows processed

0个 physical reads,说明现在用的是缓存里面保留的数据,

清除缓存:
SQL> alter system flush buffer_cache;
系统已更改。

再次执行SQL,看执行计划:
SQL> select * from awen.ob_bak where owner='AWEN';

已选择2304行。


执行计划
----------------------------------------------------------
Plan hash value: 709901947

----------------------------------------------------------------------------------------

| Id  | Operation                   | Name     | Rows  | Bytes | Cost (%CPU)| Time     |

----------------------------------------------------------------------------------------

|   0 | SELECT STATEMENT            |          |   774K|    68M| 27184   (2)| 00:00:33 |

|   1 |  TABLE ACCESS BY INDEX ROWID| OB_BAK   |   774K|    68M| 27184   (2)| 00:00:33 |

|*  2 |   INDEX RANGE SCAN          | OB_INDEX |   774K|       |  1860   (4)| 00:00:03 |

----------------------------------------------------------------------------------------


Predicate Information (identified by operation id):
---------------------------------------------------

   2 - access("OWNER"='AWEN')


统计信息
----------------------------------------------------------
          0  recursive calls
          0  db block gets
       1466  consistent gets
       1587  physical reads
          0  redo size
     220074  bytes sent via SQL*Net to client
       2068  bytes received via SQL*Net from client
        155  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
       2304  rows processed

又会有  physical reads 出现。
添加评论

昵称 *

E-mail (防止垃圾信息,此栏留空)