Thursday, 5 November 2009

Way to find the database table that is accessed the most often?

A way to find the database table that is accessed the most often?

You can query the V$SEGMENT_STATISTICS view for this information. Look for tables that have a high number of physical reads and logical reads.

The below query will give the following might provide what you are looking for:

SELECT t.owner,t.table_name,lr.value+pr.value AS total_reads
FROM (SELECT owner,object_name,value FROM v$segment_statistics
WHERE statistic_name='logical reads') lr,
SELECT owner,object_name,value FROM v$segment_statistics
WHERE statistic_name='logical reads') pr,
dba_tables t
WHERE lr.owner=pr.owner AND lr.object_name=pr.object_name
AND lr.owner=t.owner AND lr.object_name=t.table_name
ORDER BY 3;