这个tkprof文件中两个sql语句摘入如下:
- ********************************************************************************
- select count(*)
- from
- t
- call count cpu elapsed disk query current rows
- ------- ------ -------- ---------- ---------- ---------- ---------- ----------
- Parse 1 0.01 0.06 0 0 0 0
- Execute 1 0.00 0.00 0 0 0 0
- Fetch 2 0.00 0.01 6 7 0 1
- ------- ------ -------- ---------- ---------- ---------- ---------- ----------
- total 4 0.01 0.08 6 7 0 1
- Misses in library cache during parse: 1
- Optimizer mode: ALL_ROWS
- Parsing user id: 55
- Rows Row Source Operation
- ------- ---------------------------------------------------
- 1 SORT AGGREGATE (cr=7 pr=6 pw=0 time=15493 us)
- 2 TABLE ACCESS FULL T (cr=7 pr=6 pw=0 time=15449 us)
- Elapsed times include waiting on following events:
- Event waited on Times Max. Wait Total Waited
- ---------------------------------------- Waited ---------- ------------
- SQL*Net message to client 2 0.00 0.00
- db file sequential read 1 0.01 0.01
- db file scattered read 1 0.00 0.00
- SQL*Net message from client 2 0.00 0.00
注释:
从上面的输出可以看到,这条语句访问了7个块来找到需要select的记录,返回1条记录。
这个查询parse了1次,而且是hard parse 1次。
select语句主要看fetch这一行
- ********************************************************************************
- update t1 set tname='think high'
- where
- id=1
- call count cpu elapsed disk query current rows
- ------- ------ -------- ---------- ---------- ---------- ---------- ----------
- Parse 1 0.00 0.00 0 0 0 0
- Execute 1 0.00 0.03 0 5 2 1
- Fetch 0 0.00 0.00 0 0 0 0
- ------- ------ -------- ---------- ---------- ---------- ---------- ----------
- total 2 0.00 0.03 0 1 1 1
- Misses in library cache during parse: 1
- Optimizer mode: ALL_ROWS
- Parsing user id: 55
- Rows Row Source Operation
- ------- ---------------------------------------------------
- 1 UPDATE T1 (cr=1 pr=0 pw=0 time=31186 us)
- 1 INDEX UNIQUE SCAN INDEX_T1 (cr=1 pr=0 pw=0 time=23 us)(object id 54498)
- Elapsed times include waiting on following events:
- Event waited on Times Max. Wait Total Waited
- ---------------------------------------- Waited ---------- ------------
- SQL*Net message to client 1 0.00 0.00
- SQL*Net message from client 1 0.00 0.00
注释:
这条语句访问了5个block来找到需要的update的记录,在执行update的时候只访问了2个,一共更新了1条记录
DML语句主要看execute这一行
