DB2数据统计
DB2数据库在执行SQL语句之前,会使用优化器为其分配一个经过估算的执行计划。该执行计划是建议在正确的数据统计基础之上的,因此,为了保证执行计划的正确性,必须要对数据进行正确的数据统计。Runstats:
该命令是对表及索引的信息进行统计,以便为SQL执行计划的正确执行打基础。
仅对表进行统计:
db2 => runstats on table tabx
统计所有列:
db2 => runstats on table tabx on all columns
统计表及索引:
db2 => runstats on table tabx on all columns and detailed indexes all
统计索引信息:
db2 => runstats on table tabx for indexes all
全面统计:
统计表、数据分布及所有索引
db2 => runstats on table tabx on all columns with distribution and detailed indexes all
查看统计日期:
db2 => select tabname,STATS_TIME from syscat.tables
设置系统是否自动执行统计信息:
$ db2 update db cfg using AUTO_MAINT off AUTO_TBL_MAINT off AUTO_RUNSTATS off
页:
[1]