Search code examples
databaseoracleperformanceusage-statistics

In Oracle database, does SYS.COL_USAGE$ ever get reset?


Is there a way to reset the table SYS.COL_USAGE$? Does the number keep going up for ever?

Of course, I can truncate the table or do DML operations but this is a SYSTEM table and I prefer not to do that.

Background: We have an unusual data warehouse setup with two databases; a warehouse database where the overnight ETL writes to and a user database which is customer facing and is cloned before the start of the day from the warehouse database. We gather stats in the warehouse database which gets copied to the user database as part of the clone.

However, I realized that SYS.COL_USAGE$, which drives the histogram creation, are based entirely on ETL queries and not user queries.


Solution

  • DBMS_STATS.RESET_COL_USAGE is your friend here.

    https://docs.oracle.com/en/database/oracle/oracle-database/19/arpls/DBMS_STATS.html#GUID-0ED25A41-8642-46E4-AB5C-AAC08E622A8F