I am trying to gather usage statistics for a large Oracle database. I know about looking at the DBA_TAB_MODIFICATIONS view to see INSERT, UPDATE, and DELETE stats. But what about just select statements? I am trying to find tables that are never used.
SYS.DBA_HIST_SQLTEXT has a SQL_TEXT field that stores individual queries run for a specific period of time, with SQL_ID being the PK. I have thought about parsing that to pick out the table names, but that seems WAY too tedius. I am seeking another alternative.
Any ideas?
Assuming you are using a reasonably recent version of Oracle (9.2 or later I believe), you can take a look at V$SEGMENT_STATISTICS. That shows you on a segment-by-segment basis a number of different performance counters. If you look just at
statistic_name='logical reads', that will give you a good idea about what tables are read very little. Of course, even if an application never uses a table, it is entirely possible that there will be some reads logged for things like backups or recursive SQL (i.e. verifying foreign keys). And it is entirely possible that a table’s segment is rarely read but an index on that table is read frequently (i.e. the index is sufficient for most of the types of access the application needs to the table’s data).