innodb_table_stats
| 字段名 | 描述 |
|---|---|
| database_name | 数据库名 |
| table_name | 表名 |
| last_update | 本条记录最后更新时间 |
| n_rows | 表中记录数估计值 |
| clustered_index_size | 表的聚簇索引占用页面数量 |
| sum_of_other_index_sizes | 表的其他索引占用页面数量 |
- n_rows:采样几个页面确定平均每页的记录数,再乘以总页数。系统变量innodb_stats_persistent_sample_pages定义采样页数,表属性STATS_SAMPLE_PAGES单独设置单个表的采样数量。
innodb_index_stats
| 字段名 | 描述 |
|---|---|
| database_name | 数据库名 |
| table_name | 表名 |
| index_name | 索引名 |
| last_update | 本条记录最后更新时间 |
| stat_name | 统计项名称 |
| stat_value | 统计项值 |
| sample_size | 生成统计数据采样的页面数量 |
| stat_description | 统计项描述 |
统计项
| 统计项 | 描述 |
|---|---|
| n_leaf_pages | 改索引叶子节点占用页数 |
| size | 该索引共占用的页数,包括分配过的但未使用的 |
| n_diff_pfxNN | 索引前NN列不重复的的值有多少 |
| n_diff_pfx01 | 索引前1列不重复的的值有多少 |
| n_diff_pfx02 | 索引前2列不重复的的值有多少 |
| n_diff_pfx03 | 索引前3列不重复的的值有多少 |
| …… |
统计数据的更新
- 系统变量innodb_stats_auto_recalc决定是否自动重新计算统计数据,当表中记录数变化超过10%时开始异步重新统计。
- 语句analyze table tableName来手动更新某个表的统计数据
