设为首页 加入收藏

TOP

MySQL 统计数据
2015-11-10 12:16:25 来源: 作者: 【 】 浏览:0
Tags:MySQL 统计数据

1、永久化的统计数据
?默认的5.6.6后使用时这种方式,影响他的参数有
innodb_stats_persistent_sample_pages 每次采样的块数,默认为20
?innodb_stats_auto_recalc 是否开启自动收集,默认为修改量超过10%的数据
innodb_stats_persistent? 默认为ON,是否使用永久化的统计数据



?永久化的统计数据存储在innodb_index_stats和innodb_table_stats中,官方文档说统计数据并非实时的,也就是收集统计数据会滞后几分钟,如果想要及时的更新统计


数据需要手动执行ANALYZE TABLE(In some cases, statistics
?recalculation may be delayed by a few seconds. If up-to-date statistics are
?required immediately after changing significant portions of a table, run ANALYZE
?TABLEto initiate a synchronous (foreground) recalculation of statistics)


如果统计数据不准可能需要修改innodb_stats_persistent_sample_pages的值更大,如果analyze table过慢可以考虑减少innodb_stats_persistent_sample_pages的值更小。这两个表为INNODB的表



2、非永久化的统计数
?如果设置innodb_stats_persistent为OFF就使用这种方式的统计数据,这种方式的统计数据在数据库重启后就丢失,他的统计数据保存在STATISTICS,TABLES两个表中,他们是MEMORY引擎的表,这种方式受影响的参数
innodb_stats_persistent 设置为OFF
?innodb_stats_transient_sample_pages 默认为8,为采样块数
innodb_stats_on_metadata 英文描述To have statistics updated when metadata statements such as SHOW TABLE STATUS
? ? ? ? ? ? ? ? ? ? ? ? ? or SHOW INDEX are run, or when accessing the INFORMATION_SCHEMA.TABLES or
? ? ? ? ? ? ? ? ? ? ? ? ? INFORMATION_SCHEMA.STATISTICSt ables, execute the statement SET GLOBAL
? ? ? ? ? ? ? ? ? ? ? ? ? innodb_stats_on_metadata=ON


当innodb_stats_persistent设置为ON的时候,默认innodb_stats_on_metadata是OFF的,因为它会影响SHOW TABLE STATUS等的速度


最后我们再来简单描述一下ORCALE的统计数据收集的策略,ORACLE 10G,11G都是通过自动化的作业来收集,默认的11G周1到周5晚上10点开始收集统计数据,周末则是早上6点开始,当然这种收集统计数据并不是全部收集,ORACLE会把修改数量超过10%的TABLES记录到mon_mods_all$内部表中,然后对这些表进行收集,这样来保证统计数据能够尽可能的描述数据的分布,同时ORACLE会通过谓词的使用来判定是否收集直方图,?谓词的使用记录在COL_USAGE$内部视图中,直方图用于判定数据的倾斜,MYSQL在这方面视乎还没有。


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Oracle 11.2.0.3和MySQL5.6 DDL比.. 下一篇遭遇 ORA-00600: internal error ..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: