数据库表信息统计

一般当数据库中某一张表有超过20%以上的数据有变化更新时,都需要做一次表统计信息。

一般无较慢sql但数据库CPU使用率较高时,较大原因为表统计信息不对,导致sql执行计划不对。

 

Oracle表统计信息查看

select table_name,num_rows,blocks, AVG_ROW_LEN, LAST_ANALYZED from user_tab_statistics where table_name  = '大写表名';

 

Oracle执行表信息统计

exec dbms_stats.gather_table_stats('Schema', '大写表名');

或者

analyze table大写表名delete statistics;

analyze table大写表名compute statistics;

analyze table大写表名compute statistics for all indexes;

 

DB2表统计信息查看

select tabname,STATS_TIME,CARD from syscat.tables where tabname= '大写表名';

 

Db2执行表信息统计

命令行执行 db2 runstats on table DB2INST1.表名 with distribution and detailed indexes all

 

注意:一般db2数据做删除、导入导出等操作会产生碎片,影响性能,需要做碎片整理。

Db2 reorg table DB2INST1.表名

猜你喜欢

转载自blog.csdn.net/qq_30599553/article/details/86027911