该文章的作者给予了极大的帮助长老枯荣,为了表达我的谢意。
这适用于oracle db版本号oracle 10g或者更高的版本号.
之所以说这种看法是非常重要的,因为观点是有之一awrsqrpt报告没有在。就是 filter_predicates列。
SELECT plan_hash_value,
TO_CHAR(RAWTOHEX(child_address)),
TO_NUMBER(child_number),
id,
LPAD(' ', DEPTH) || operation operation,
options,
object_owner,
object_name,
optimizer,
cost,
access_predicates,
filter_predicates
FROM V$SQL_PLAN
WHERE sql_id = 'bkcyk7bf380t6'
ORDER BY 1, 3, 2, 4;
重点关注optimizer列,filter_predicates列。
若是该sql不在shared pool中时,改为运行例如以下的sql:
set linesize 500
set pagesize 500
col plan_hash_value format 9999999999
col id format 999999
col operation format a30
col options format a15
col object_owner format a15
col object_name format a20
col optimizer format a15
col cost format 9999999999
col access_predicates format a15
col filter_predicates format a15
SELECT plan_hash_value,
id,
LPAD (' ', DEPTH) || operation operation,
options,
object_owner,
object_name,
optimizer,
cost,
access_predicates,
filter_predicates
FROM dba_hist_sql_plan
WHERE sql_id = 'fahv8x6ngrb50'
ORDER BY plan_hash_value, id;
重点关注filter_predicates列。
--这一列能帮助推断不走索引的原因。
这一列的查询结果若是为null,那就是正常的。若是不为null,那就须要额外关注不为空的原因。例如以下图所看到的: