全部博文(389)
分类: Mysql/postgreSQL
2014-10-17 16:29:43
如何计算mysql数据库大小
mysql大小可以通过 information_schema.tables中得出,不过内部开销不计算在内,所以是一个
近似的值
select
t.TABLE_SCHEMA "db name",
round(sum(t.INDEX_LENGTH+t.DATA_LENGTH)/1024/1024,2) "database size MB"
from information_schema.TABLES t
group by t.TABLE_SCHEMA
mysql> select
-> t.TABLE_SCHEMA "db name",
-> round(sum(t.INDEX_LENGTH+t.DATA_LENGTH)/1024/1024,2) "database size MB"
-> from information_schema.TABLES t
-> group by t.TABLE_SCHEMA
-> ;
+--------------------+------------------+
| db name | database size MB |
+--------------------+------------------+
| db1 | 0.09 |
| information_schema | 0.01 |
| mysql | 0.91 |
| performance_schema | 0.00 |
| zabbix | 20.80 |
+--------------------+------------------+
5 rows in set (0.01 sec)