免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2402 | 回复: 0
打印 上一主题 下一主题

mysql表空间及索引大小的查看 [复制链接]

论坛徽章:
9
每日论坛发贴之星
日期:2016-01-04 06:20:00数据库技术版块每日发帖之星
日期:2016-01-04 06:20:00每日论坛发贴之星
日期:2016-01-04 06:20:00数据库技术版块每日发帖之星
日期:2016-01-04 06:20:00IT运维版块每日发帖之星
日期:2016-01-04 06:20:00IT运维版块每日发帖之星
日期:2016-01-04 06:20:00综合交流区版块每日发帖之星
日期:2016-01-04 06:20:00综合交流区版块每日发帖之星
日期:2016-01-04 06:20:00数据库技术版块每周发帖之星
日期:2016-03-07 16:30:25
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-09-12 11:17 |只看该作者 |倒序浏览
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

               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/90603/showart_2050861.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP