← Statistics
Oracle · Statistics
How to find tables with stale optimizer statistics in Oracle
List Oracle tables, partitions, and subpartitions whose optimizer statistics are marked stale in DBA_TAB_STATISTICS.
Tested on11g12c18c19c21c23ai26ai
STALE_STATS = ''YES'' means data has changed enough since the last gather that the optimizer may choose a bad plan. Rebuild stats for these objects with DBMS_STATS.GATHER_TABLE_STATS or let the autotask handle them in the next maintenance window.
COL table_name FORMAT a30
COL partition_name FORMAT a20
COL subpartition_name FORMAT a20
SELECT owner,
table_name,
partition_name,
subpartition_name,
num_rows,
last_analyzed
FROM dba_tab_statistics
WHERE stale_stats = 'YES';statisticsstale statsdba_tab_statisticsoptimizer