--通过包来刷新数据库监控信息
exec dbms_stats.flush_database_monitoring_info;
--找到从未收集过统计信息或者统计信息过期的表
select owner,table_name,object_type,stale_stats,last_analyzed
from
dba_tab_statistics
where (stale_stats='YES' or last_analyzed is null)
and owner not in ('SYS', 'SYSTEM', 'SYSMAN', 'DMSYS', 'OLAPSYS', 'XDB','EXFSYS',
'CTXSYS', 'WMSYS', 'DBSNMP', 'ORDSYS', 'OUTLN', 'TSMSYS', 'MDSYS')
and table_name not like 'BIN%';
--在SQL调优之前,我们就要看表的统计信息是否过期,若过期,CBO就可能选择错误的执行计划
select owner,table_name,object_type,stale_stats,last_analyzed
from
dba_tab_statistics
where owner='&owner' and table_name='&table_name';
(责任编辑:OracleTT) |