SQL> var v number SQL> exec :v :=1 ---传入参数为1 ,此时Oracle应该放弃索引,使用全表扫描
PL/SQL procedure successfully completed.
SQL> @$ORACLE_BASE/eygle.sql
[oracle@jumper udump]$ tkprof *.trc e1.log
TKPROF: Release 9.2.0.3.0 - Production on Thu Nov 20 23:49:28 2003
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
[oracle@jumper udump]$ vi e1.log
TKPROF: Release 9.2.0.3.0 - Production on Thu Nov 20 23:49:28 2003
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Trace file: hsjf_ora_16137.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 ********************************************************************************
alter session set sql_trace = true
call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 0 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 1 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0 Optimizer goal: CHOOSE Parsing user id: 96 ********************************************************************************
select * from t where id = :v
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 2713 0.50 0.47 0 3239 0 40671 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 2715 0.51 0.48 0 3239 0 40671
Misses in library cache during parse: 1 Optimizer goal: CHOOSE Parsing user id: 96
Rows Row Source Operation ------- --------------------------------------------------- 40671 TABLE ACCESS FULL T (cr=3239 r=0 w=0 time=246446 us)
-----------由于柱状图信息生效,此处使用了全表扫描
********************************************************************************
Peek here
select /*+ rule */ bucket_cnt, row_cnt, cache_cnt, null_cnt, timestamp#, sample_size, minimum, maximum, distcnt, lowval, hival, density, col#, spare1, spare2, avgcln from hist_head$ where obj#=:1 and intcol#=:2
call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.00 0.00 0 0 0 0 Execute 13 0.00 0.00 0 0 0 0 Fetch 13 0.00 0.00 0 26 0 0 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 27 0.00 0.00 0 26 0 0
Misses in library cache during parse: 0 Optimizer goal: RULE Parsing user id: SYS (recursive depth: 1) ********************************************************************************
alter session set sql_trace = false
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
|