mysql表空间及索引大小的查看
2013-01-04 15:51
399 查看
Calculate index sizes
mysql> SELECT CONCAT(ROUND(SUM(index_length)/(1024*1024*1024), 2), ' GB') AS 'Total Index Size'
FROM information_schema.TABLES WHERE table_schema LIKE 'database';
+------------------+
| Total Index Size |
+------------------+
| 1.70 GB |
+------------------+
1 row in set (1.60 sec)
To calculate the total size of the data in the database
mysql> SELECT CONCAT(ROUND(SUM(data_length)/(1024*1024*1024), 2), ' GB') AS 'Total Data Size'
FROM information_schema.TABLES WHERE table_schema LIKE 'database';
+-----------------+
| Total Data Size |
+-----------------+
| 3.01 GB |
+-----------------+
1 row in set (1.35 sec)
An overall analysis of entire database on a per table basis
SELECT CONCAT(table_schema,'.',table_name) AS 'Table Name',
CONCAT(ROUND(table_rows/1000000,2),'M') AS 'Number of Rows',
CONCAT(ROUND(data_length/(1024*1024*1024),2),'G') AS 'Data Size',
CONCAT(ROUND(index_length/(1024*1024*1024),2),'G') AS 'Index Size' ,
CONCAT(ROUND((data_length+index_length)/(1024*1024*1024),2),'G') AS'Total'FROM information_schema.TABLES WHERE table_schema LIKE 'database';
Just replace database with the partial name of your database you need to analyze. Yes, I know, those wonderful Maatkit tools contains mk-find which can do the same thing, but then you won't learn about the information_schema database!!
MySQL DBA & Programming Blog by Mark Schoonover
mysql> SELECT CONCAT(ROUND(SUM(index_length)/(1024*1024*1024), 2), ' GB') AS 'Total Index Size'
FROM information_schema.TABLES WHERE table_schema LIKE 'database';
+------------------+
| Total Index Size |
+------------------+
| 1.70 GB |
+------------------+
1 row in set (1.60 sec)
To calculate the total size of the data in the database
mysql> SELECT CONCAT(ROUND(SUM(data_length)/(1024*1024*1024), 2), ' GB') AS 'Total Data Size'
FROM information_schema.TABLES WHERE table_schema LIKE 'database';
+-----------------+
| Total Data Size |
+-----------------+
| 3.01 GB |
+-----------------+
1 row in set (1.35 sec)
An overall analysis of entire database on a per table basis
SELECT CONCAT(table_schema,'.',table_name) AS 'Table Name',
CONCAT(ROUND(table_rows/1000000,2),'M') AS 'Number of Rows',
CONCAT(ROUND(data_length/(1024*1024*1024),2),'G') AS 'Data Size',
CONCAT(ROUND(index_length/(1024*1024*1024),2),'G') AS 'Index Size' ,
CONCAT(ROUND((data_length+index_length)/(1024*1024*1024),2),'G') AS'Total'FROM information_schema.TABLES WHERE table_schema LIKE 'database';
Just replace database with the partial name of your database you need to analyze. Yes, I know, those wonderful Maatkit tools contains mk-find which can do the same thing, but then you won't learn about the information_schema database!!
MySQL DBA & Programming Blog by Mark Schoonover
相关文章推荐
- mysql表空间及索引大小的查看
- mysql 表空间大小及索引的查看
- mysql 表空间及索引大小的查看
- MySQL查看表占用空间大小
- postgresql 查看数据库,表,索引,表空间以及大小
- 查看 MySQL 数据库中每个表占用的空间大小
- 统计 MySQL 数据库中每个表数据与索引占用的空间大小
- 查看mysql库大小,表大小,索引大小
- 查看 MySQL 数据库中每个表占用的空间大小
- 查看 MySQL 数据库中每个表占用的空间大小
- PostgreSQL查看数据库,索引,表空间大小
- 查看 MySQL 数据库中每个表占用的空间大小
- 查看SQL Server数据库表、索引视图等占用的空间大小
- 查看 MySQL 数据库中每个表占用的空间大小
- 查看MySQL中每张表占用的空间大小
- 【mysql监控】查看mysql库大小,表大小,索引大小
- 查看mysql表的数据大小和索引大小
- 转载:PostgreSQL 查看数据库,索引,表,表空间大小
- MySQL查看数据库、表的占用空间大小
- 查看 MySQL 数据库中每个表占用的空间大小