关于MySQL 查询表数据大小的总结
关于MySQL 查询表数据大小的总结
- 一:关于mysql表数据大小
- 我们知道mysql存储数据文件一般使用表空间存储
- 当mysql使用innodb存储引擎的时候,
- mysql使用表存储数据分为共享表空间和独享表空间两种方式
- ·共享表空间:Innodb的所有数据保存在一个单独的表空间里面,而这个表空间可以由很多个文件组成,一个表可以跨多个文件存在。
- 所以其大小限制不再是文件大小的限制,而是其自身的限制
- -->innodb官方显示表空间的最大限制为64TB
- ·独享表空间:每个表的数据以一个单独的文件来存放,这个时候的单表限制,又变成文件系统的大小限制了
- 在默认情况下,MySQL创建的MyISAM表允许的最大尺寸为4GB
- 二:关于show table stauts\G;中显示内容的解释
- Data_length: 150032--->表中数据的大小
- Index_length: 183107584--->表的索引的大小
- Data_free: 25238175744--->表空间的大小
- data_Free :如果是共享表空间 data_free 是共享表空间的大小而非数据的大小。
- 如果是独享表空间才是该表的剩余空间。
- 如果表是分区存储的,data_free 就是一个近似值而非精确值所以此时需要查询
- select sum(data_free) from information_schema.partitions where table_schema = 'db_name' and table_name='tab_name';
- 查询所有数据库的大小
- 1:use information_schema;
- select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables;
- 2:select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables where table_schema='database_name';
- 3: 查询指定表的大小
- select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables where table_schema='database_name' and table_name='table_name';
- 三:判断mysql I/0 性能的一种方式(网络搜集供参考)
- show global status like 'innodb_dblwr%'\G
- 如果innodb_dblwr_pages_writen/innodb_dblwr_writes远小于64:1,说明磁盘写入压力不高
- show engine innodb status\G 查看缓冲池的方法。
- select table_name,data_length+index_length,table_rows from tables where table_schema='database_name' and table_name='table_name';
备注:朋友们上述有错误的地方还望提出来,多多指教,联系笔者或者留言,谢谢! |
本文出自 “好望角” 博客,请务必保留此出处http://haicang.blog.51cto.com/2590303/1112676
!!!我的新站地址点击这里,欢迎光顾!!!