Subscribe to Posts by Email

Subscriber Count

    699

Disclaimer

All information is offered in good faith and in the hope that it may be of use for educational purpose and for Database community purpose, but is not guaranteed to be correct, up to date or suitable for any particular purpose. db.geeksinsight.com accepts no liability in respect of this information or its use. This site is independent of and does not represent Oracle Corporation in any way. Oracle does not officially sponsor, approve, or endorse this site or its content and if notify any such I am happy to remove. Product and company names mentioned in this website may be the trademarks of their respective owners and published here for informational purpose only. This is my personal blog. The views expressed on these pages are mine and learnt from other blogs and bloggers and to enhance and support the DBA community and this web blog does not represent the thoughts, intentions, plans or strategies of my current employer nor the Oracle and its affiliates or any other companies. And this website does not offer or take profit for providing these content and this is purely non-profit and for educational purpose only. If you see any issues with Content and copy write issues, I am happy to remove if you notify me. Contact Geek DBA Team, via geeksinsights@gmail.com

Pages

Script for Staleness Percent for each table

Ever, interested in looking for statistics staleness for each table including how much percent they stale are. The following query helps you to get you the details.

This query filter out the staleness for those tables which having more than or equal to 10%, you can adjust accordingly.

However, you will need to understand how this details are populated by reading this post, http://db.geeksinsight.com/2013/01/03/stats-change-statistics-stale-percentage-in-11g/

To change the database level statistics preferences for staleness , you need to do following.

SQL>  Select dbms_stats.GET_PREFS('STALE_PERCENT') from dual;

DBMS_STATS.GET_PREFS('STALE_PERCENT')

---------------------------------------------

10

SQL> exec dbms_stats.set_database_prefs('STALE_PERCENT',9);

Back to the point, here is the query,

 

set heading on

set pages 1000

set lines 100

SELECT DT.OWNER,

DT.TABLE_NAME,

dtm.inserts,

dtm.deletes,

dtm.updates,

dtm.truncated,

dt.last_analyzed,

dt.num_rows,

ROUND ( (DELETES + UPDATES + INSERTS) / NUM_ROWS * 100) PERCENTAGE

FROM DBA_TABLES DT, DBA_TAB_MODIFICATIONS DTM

WHERE DT.OWNER = DTM.TABLE_OWNER

AND DT.TABLE_NAME = DTM.TABLE_NAME

AND NUM_ROWS > 0

--AND ROUND ( (DELETES + UPDATES + INSERTS) / NUM_ROWS * 100) >= 10

AND DT.TABLE_NAME='TSTS076'

ORDER BY 9 desc;

 

 

Click to Enlarge the screenshot

Hope it helps

Geek DBA

Comments are closed.