|
用Tkprof处理生成的trace文件。因为在存在绑定变量窥视时,autotrace或者explain plan可能不会显示正确的查询计划,需要Tkprof来处理sql trace。 tkprof fuyuncat_ora_5352.trc aaa.txt
此时OPTIMIZER_INDEX_COST_ADJ是60,根据上面的结论,似乎查询计划应该选择扫描索引。但是,这里给绑定变量赋了值"A",这时,优化器会“窥视”到这个值,并且在计算扫描成本时按照这个值的成本来计算。因此,得出的查询计划是全表扫描,而不是扫描索引,靠Tkprof分析的结果: 以下是引用片段: select * from T_PEEKING a where b = :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 68 0.01 0.07 0 406 0 1000 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 70 0.01 0.08 0 406 0 1000 Misses in library cache during parse: 1 Optimizer mode: CHOOSE Parsing user id: SYS Rows Row Source Operation ------- --------------------------------------------------- 1000 TABLE ACCESS FULL T_PEEKING (cr=406 pr=0 pw=0 time=5052 us) |