alter system flush buffer_cache;
做一个10046时间,观察trace内容
set linesize 200 set timing on alter session set tracefile_identifier='fenyetest0'; alter session set events '10046 trace name context forever,level 4'; variable start_num number; variable end_num number; --1. 10000-2000数据 exec :start_num := 10000; exec :end_num := 20000; select * from ( select rownum rn,t.* from (select OPERATE_TIME,SERVER_INFO ,ACCESS_IP ,USERID from bi_logfile where OPERATE_TIME>=(sysdate-10)) t where rownum<:end_num) where rn >:start_num; --查看buffer_cache中的内容 SQL> SELECT o.OBJECT_NAME, COUNT(*) NUMBER_OF_BLOCKS FROM DBA_OBJECTS o, V$BH bh WHERE o.DATA_OBJECT_ID = bh.OBJD AND o.OWNER ='JSCNBI' GROUP BY o.OBJECT_NAME ORDER BY COUNT(*); OBJECT_NAME NUMBER_OF_BLOCKS ---------------------------------------- ---------------- BI_LOGFILE_IDX1 128 BI_LOGFILE 1160 --2. 20000-3000数据 exec :start_num := 20000; exec :end_num := 30000; select * from ( select rownum rn,t.* from (select OPERATE_TIME,SERVER_INFO ,ACCESS_IP ,USERID from bi_logfile where OPERATE_TIME>=(sysdate-10)) t where rownum<:end_num) where rn >:start_num; --查看buffer_cache中的内容 SQL> SELECT o.OBJECT_NAME, COUNT(*) NUMBER_OF_BLOCKS FROM DBA_OBJECTS o, V$BH bh WHERE o.DATA_OBJECT_ID = bh.OBJD AND o.OWNER ='JSCNBI' GROUP BY o.OBJECT_NAME ORDER BY COUNT(*); 2 3 4 5 6 OBJECT_NAME NUMBER_OF_BLOCKS ---------------------------------------- ---------------- BI_LOGFILE_IDX1 197 BI_LOGFILE 1665 --3. 30000-40000数据 exec :start_num := 30000; exec :end_num := 40000; select * from ( select rownum rn,t.* from (select OPERATE_TIME,SERVER_INFO ,ACCESS_IP ,USERID from bi_logfile where OPERATE_TIME>=(sysdate-10)) t where rownum<:end_num) where rn >:start_num; --查看buffer_cache中的内容 SQL> SELECT o.OBJECT_NAME, COUNT(*) NUMBER_OF_BLOCKS FROM DBA_OBJECTS o, V$BH bh WHERE o.DATA_OBJECT_ID = bh.OBJD AND o.OWNER ='JSCNBI' GROUP BY o.OBJECT_NAME ORDER BY COUNT(*); 2 3 4 5 6 OBJECT_NAME NUMBER_OF_BLOCKS ---------------------------------------- ---------------- BI_LOGFILE_IDX1 222 BI_LOGFILE 1983 alter session set events '10046 trace name context off';
TKPROF: Release 10.2.0.4.0 - Production on Fri Jul 13 13:57:48 2012 Copyright (c) 1982, 2007, Oracle. All rights reserved. Trace file: jscnbi_ora_27002_fenyetest0.trc Sort options: default ******************************************************************************** count = number of times OCI procedure was executed cpu = cpu time in seconds executing elapsed = elapsed time in seconds executing disk = number of physical reads of buffers from disk query = number of buffers gotten for consistent read current = number of buffers gotten in current mode (usually for update) rows = number of rows processed by the fetch or execute call -------------------------------------------------------------------------------- *** SESSION ID:(309.11) 2012-07-13 13:56:17.864 ******************************************************************************** BEGIN :start_num := 10000; END; call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.00 0.00 0 0 0 0 Execute 1 0.00 0.00 0 0 0 1 Fetch 0 0.00 0.00 0 0 0 0 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 2 0.00 0.00 0 0 0 1 Misses in library cache during parse: 1 Misses in library cache during execute: 1 Optimizer mode: ALL_ROWS Parsing user id: 59 ******************************************************************************** BEGIN :end_num := 20000; END; call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.00 0.00 0 0 0 0 Execute 1 0.00 0.00 0 0 0 1 Fetch 0 0.00 0.00 0 0 0 0 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 2 0.00 0.00 0 0 0 1 Misses in library cache during parse: 1 Misses in library cache during execute: 1 Optimizer mode: ALL_ROWS Parsing user id: 59 ******************************************************************************** select * from ( select rownum rn,t.* from (select OPERATE_TIME,SERVER_INFO ,ACCESS_IP ,USERID from bi_logfile where OPERATE_TIME>=(sysdate-10)) t where rownum<:end_num) where rn >:start_num call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.00 0.00 0 0 0 0 Execute 1 0.00 0.00 0 0 0 0 Fetch 668 0.12 0.09 1274 11081 0 9999 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 670 0.12 0.10 1274 11081 0 9999 Misses in library cache during parse: 1 Optimizer mode: ALL_ROWS Parsing user id: 59 Rows Row Source Operation ------- --------------------------------------------------- 9999 VIEW (cr=11081 pr=1274 pw=0 time=84845 us) 19999 COUNT STOPKEY (cr=11081 pr=1274 pw=0 time=81070 us) 19999 TABLE ACCESS BY INDEX ROWID BI_LOGFILE (cr=11081 pr=1274 pw=0 time=81068 us) 19999 INDEX RANGE SCAN BI_LOGFILE_IDX1 (cr=743 pr=127 pw=0 time=676 us)(object id 52405) ******************************************************************************** BEGIN :start_num := 20000; END; call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.00 0.00 0 0 0 0 Execute 1 0.00 0.00 0 0 0 1 Fetch 0 0.00 0.00 0 0 0 0 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 2 0.00 0.00 0 0 0 1 Misses in library cache during parse: 1 Misses in library cache during execute: 1 Optimizer mode: ALL_ROWS Parsing user id: 59 ******************************************************************************** BEGIN :end_num := 30000; END; call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.00 0.00 0 0 0 0 Execute 1 0.00 0.00 0 0 0 1 Fetch 0 0.00 0.00 0 0 0 0 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 2 0.00 0.00 0 0 0 1 Misses in library cache during parse: 1 Misses in library cache during execute: 1 Optimizer mode: ALL_ROWS Parsing user id: 59 ******************************************************************************** select * from ( select rownum rn,t.* from (select OPERATE_TIME,SERVER_INFO ,ACCESS_IP ,USERID from bi_logfile where OPERATE_TIME>=(sysdate-10)) t where rownum<:end_num) where rn >:start_num call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.00 0.00 0 0 0 0 Execute 1 0.00 0.00 0 0 0 0 Fetch 668 0.15 0.11 586 16100 0 9999 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 670 0.15 0.11 586 16100 0 9999 Misses in library cache during parse: 0 Optimizer mode: ALL_ROWS Parsing user id: 59 Rows Row Source Operation ------- --------------------------------------------------- 9999 VIEW (cr=16100 pr=586 pw=0 time=111363 us) 29999 COUNT STOPKEY (cr=16100 pr=586 pw=0 time=120067 us) 29999 TABLE ACCESS BY INDEX ROWID BI_LOGFILE (cr=16100 pr=586 pw=0 time=90064 us) 29999 INDEX RANGE SCAN BI_LOGFILE_IDX1 (cr=781 pr=78 pw=0 time=74 us)(object id 52405) ******************************************************************************** BEGIN :start_num := 30000; END; call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.00 0.00 0 0 0 0 Execute 1 0.00 0.00 0 0 0 1 Fetch 0 0.00 0.00 0 0 0 0 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 2 0.00 0.00 0 0 0 1 Misses in library cache during parse: 1 Misses in library cache during execute: 1 Optimizer mode: ALL_ROWS Parsing user id: 59 ******************************************************************************** BEGIN :end_num := 40000; END; call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.00 0.00 0 0 0 0 Execute 1 0.00 0.00 0 0 0 1 Fetch 0 0.00 0.00 0 0 0 0 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 2 0.00 0.00 0 0 0 1 Misses in library cache during parse: 1 Misses in library cache during execute: 1 Optimizer mode: ALL_ROWS Parsing user id: 59 ******************************************************************************** select * from ( select rownum rn,t.* from (select OPERATE_TIME,SERVER_INFO ,ACCESS_IP ,USERID from bi_logfile where OPERATE_TIME>=(sysdate-10)) t where rownum<:end_num) where rn >:start_num call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.00 0.00 0 0 0 0 Execute 1 0.00 0.00 0 0 0 0 Fetch 668 0.13 0.11 345 20964 0 9999 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 670 0.13 0.11 345 20964 0 9999 Misses in library cache during parse: 0 Optimizer mode: ALL_ROWS Parsing user id: 59 Rows Row Source Operation ------- --------------------------------------------------- 9999 VIEW (cr=20964 pr=345 pw=0 time=109073 us) 39999 COUNT STOPKEY (cr=20964 pr=345 pw=0 time=120041 us) 39999 TABLE ACCESS BY INDEX ROWID BI_LOGFILE (cr=20964 pr=345 pw=0 time=120035 us) 39999 INDEX RANGE SCAN BI_LOGFILE_IDX1 (cr=817 pr=16 pw=0 time=109 us)(object id 52405) ******************************************************************************** alter session set events '10046 trace name context off' call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.00 0.00 0 0 0 0 Execute 1 0.00 0.00 0 0 0 0 Fetch 0 0.00 0.00 0 0 0 0 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 2 0.00 0.00 0 0 0 0 Misses in library cache during parse: 0 Parsing user id: 59 ******************************************************************************** OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 10 0.00 0.00 0 0 0 0 Execute 10 0.01 0.01 0 0 0 6 Fetch 2004 0.41 0.32 2205 48145 0 29997 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 2024 0.42 0.34 2205 48145 0 30003 Misses in library cache during parse: 7 Misses in library cache during execute: 6 OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 15 0.00 0.00 0 0 0 0 Execute 220 0.06 0.06 0 0 0 0 Fetch 236 0.01 0.01 48 699 0 2077 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 471 0.08 0.08 48 699 0 2077 Misses in library cache during parse: 13 Misses in library cache during execute: 13 10 user SQL statements in session. 220 internal SQL statements in session. 230 SQL statements in session. ******************************************************************************** Trace file: jscnbi_ora_27002_fenyetest0.trc Trace file compatibility: 10.01.00 Sort options: default 1 session in tracefile. 10 user SQL statements in trace file. 220 internal SQL statements in trace file. 230 SQL statements in trace file. 21 unique SQL statements in trace file. 7288 lines in trace file. 35 elapsed seconds in trace file.
--取0行数据 select * from ( select rownum rn,t.* from (select OPERATE_TIME,SERVER_INFO ,ACCESS_IP ,USERID from bi_logfile where OPERATE_TIME>=(sysdate-10)) t where rownum<2) where rn >1; --查看buffer cache中有没有bi_logfile表的数据 SQL> SELECT o.OBJECT_NAME, COUNT(*) NUMBER_OF_BLOCKS FROM DBA_OBJECTS o, V$BH bh WHERE o.DATA_OBJECT_ID = bh.OBJD AND o.OWNER ='JSCNBI' GROUP BY o.OBJECT_NAME ORDER BY COUNT(*);