Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I check the last time stats was run on Oracle without using OEM

Tags:

I want to check the last time stats was run on my Oracle 10g server. I would normally do this via OEM, but for unrelated reasons OEM is down. Is there some way I can check this using just sqlplus? It would be extra helpful if the output was reasonably formatted.

like image 638
Jacob Avatar asked Mar 03 '10 21:03

Jacob


People also ask

How do you check if statistics are up to date in Oracle?

To see if Oracle thinks the statistics on your table are stale, you want to look at the STALE_STATS column in DBA_STATISTICS. If the column returns “YES” Oracle believes that it's time to re-gather stats. However, if the column returns “NO” then Oracle thinks that the statistics are up-to-date.

Where are statistics stored in Oracle?

The database stores optimizer statistics in the data dictionary. You can access these statistics using data dictionary views. Because objects in a database can change constantly, you must update statistics regularly so that they accurately describe these objects.

How can we view last record added to a table in Oracle?

You could use ORA_ROWSCN to get the last scn for each block on the table as an *approximate* means of seeing when things happened, or the flashback query syntax to get transaction information, but you are limited to the undo_retention settings on your database.


1 Answers

All of the following data dictionary tables have a LAST_ANALYZED column (replace * with USER/ALL/DBA as appropriate:

*_TABLES *_TAB_PARTITIONS *_TAB_SUBPARTITIONS *_INDEXES *_IND_PARTITIONS *_IND_SUBPARTITIONS 

(There's lots more in the histograms fields, but I'm not going that deep.)

Conversely, ALL_TAB_MODIFICATIONS shows rows inserted/updated/deleted (or the timestamp on which a table/partition/subpartition was truncated) since it had optimizer statistics gathered.

like image 82
Adam Musch Avatar answered Oct 04 '22 13:10

Adam Musch