Get the App
SLTechnology News&Howtos  ›  Database  › 

How to find tables in the database that do not collect statistics and whose statistics are out of date

Shulou Source: shulou.com Published: 2022-05-31 15:21:02 10月01日 Update

Editor to share with you how to find out the tables in the database that have not collected statistical information and statistical information is out of date. I hope you will gain something after reading this article. Let's discuss it together.

The following query finds tables that have never collected statistics or whose statistics are out of date.

EXEC DBMS_STATS.FLUSH_DATABASE_MONITORING_INFO

SELECT OWNER,TABLE_NAME,OBJECT_TYPE,STALE_STATS,LAST_ANALYZED FROM

DBA_TAB_STATISTICS WHERE (STALE_STATS='YES' OR LAST_ANALYZED IS NULL)

AND OWNER NOT IN ('SYS',' SYSTEM', 'SYSMAN',' DMSYS', 'OLAPSYS',' XDB','EXFSYS', 'CTXSYS'

'WMSYS', 'DBSNMP',' ORDSYS', 'OUTLN',' TSMSYS', 'MDSYS') AND TABLE_NAME NOT LIKE' BIN%'

Before tuning, we need to see if the statistics of the table are out of date, and if so, CBO may choose the wrong execution plan.

SELECT OWNER,TABLE_NAME,OBJECT_TYPE,STALE_STATS,LAST_ANALYZED FROM DBA_TAB_STATISTICS WHERE OWNER='&OWNER' AND TABLE_NAME='&TABLE_NAME'

After reading this article, I believe you have a certain understanding of "how to find tables in the database that do not collect statistical information and statistical information is out of date". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!

Tags: Information statistics data database articles never finished more knowledge industry information information channels errors channels queries selections Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft macOS Docker Xiaomi Shulou Technology