最近有朋友问了一个问题,
如何统计出表的活跃度?即统计出经常被访问使用的表。
我觉得有几种思路,
应用记录日志,可以根据需要,更精确地统计,满足各种定制化需求。
可以使用数据库审计功能,支持各种粒度的审计,但是会有些消耗,只要系统负责可以支持,算是一种比较科学的方法。
DBA_HIST_SEG_STAT这张视图,可能有些帮助,记录了各种维度的统计数据。
DBA_HIST_SEG_STAT displays historical information about segment-level statistics. This view captures the top segments based on a set of criteria and captures information from V$SEGSTAT. The total value is the value of the statistics since instance startup. The delta value is the value of the statistics from the BEGIN_INTERVAL_TIME to the END_INTERVAL_TIME in the DBA_HIST_SNAPSHOT view.
- DBA/USER/ALL_TAB_MODIFICATION视图,作为Oracle统计信息,自动采集的依据,也可以间接了解,但可能比较粗,且数据不是实时刷新,
ALL_TAB_MODIFICATIONS describes tables accessible to the current user that have been modified since the last time statistics were gathered on the tables.
Note: These views are populated only for tables with the MONITORING attribute. They are intended for statistics collection over a long period of time. For performance reasons, the Oracle Database does not populate these views immediately when the actual modifications occur. Run the FLUSH_DATABASE_MONITORING_INFO procedure in the DBMS_STATS PL/SQL package to populate these views with the latest information. The ANALYZE_ANY system privilege is required to run this procedure.
视图中有INSERT、UPDATE、DELETE、TRUNCATED统计,
各位若有其他的想法、思路,可以提出来一起讨论。
如果您觉得本文有帮助,欢迎关注转发:bisal的个人杂货铺,