[轉]【mysql監控】查看mysql庫大小,表大小,索引大小

來源:互聯網
上載者:User

標籤:har   指定表   指定   sch   for   ror   orm   mys   data   

本文轉自:http://blog.sina.com.cn/s/blog_4c197d420101fbl9.html

查看所有庫的大小mysql> use information_schema;Database changedmysql> select concat(round(sum(DATA_LENGTH/1024/1024),2),‘MB‘) as data  from TABLES;+----------+| data     |+----------+| 104.21MB |+----------+1 row in set (0.11 sec) 查看指定庫的大小mysql> select concat(round(sum(DATA_LENGTH/1024/1024),2),‘MB‘) as data  from TABLES where table_schema=‘jishi‘;+---------+| data    |+---------+| 26.17MB |+---------+1 row in set (0.01 sec) 查看指定庫的指定表的大小mysql> select concat(round(sum(DATA_LENGTH/1024/1024),2),‘MB‘) as data  from TABLES where table_schema=‘jishi‘ and table_name=‘a_ya‘;+--------+| data   |+--------+| 0.02MB |+--------+1 row in set (0.00 sec) 查看指定庫的索引大小mysql> SELECT CONCAT(ROUND(SUM(index_length)/(1024*1024), 2), ‘ MB‘) AS ‘Total Index Size‘ FROM TABLES  WHERE table_schema = ‘jishi‘; +------------------+| Total Index Size |+------------------+| 0.94 MB          |+------------------+1 row in set (0.01 sec) 查看指定庫的指定表的索引大小 mysql> SELECT CONCAT(ROUND(SUM(index_length)/(1024*1024), 2), ‘ MB‘) AS ‘Total Index Size‘ FROM TABLES  WHERE table_schema = ‘test‘ and table_name=‘a_yuser‘; +------------------+| Total Index Size |+------------------+| 21.84 MB         |+------------------+1 row in set (0.00 sec)mysql> show create table test.a_yuser\G;*************************** 1. row ***************************       Table: a_yuserCreate Table: CREATE TABLE `a_yuser` (  `email` varchar(60) NOT NULL DEFAULT ‘‘,  `user_name` varchar(60) NOT NULL DEFAULT ‘‘,  KEY `cc` (`email`(5)),  KEY `ccb` (`user_name`(5)),  KEY `ccbc` (`email`(5),`user_name`(5))) ENGINE=MyISAM DEFAULT CHARSET=utf81 row in set (0.00 sec) ERROR: No query specified mysql> select count(*) from test.a_yuser;+----------+| count(*) |+----------+|  1073607 |+----------+1 row in set (0.00 sec) mysql> 查看一個庫中的情況...mysql>  SELECT CONCAT(table_schema,‘.‘,table_name) AS ‘Table Name‘, CONCAT(ROUND(table_rows/1000000,4),‘M‘) AS ‘Number of Rows‘, CONCAT(ROUND(data_length/(1024*1024*1024),4),‘G‘) AS ‘Data Size‘, CONCAT(ROUND(index_length/(1024*1024*1024),4),‘G‘) AS ‘Index Size‘, CONCAT(ROUND((data_length+index_length)/(1024*1024*1024),4),‘G‘) AS‘Total‘FROM information_schema.TABLES WHERE table_schema LIKE ‘test‘;+---------------+----------------+-----------+------------+---------+| Table Name    | Number of Rows | Data Size | Index Size | Total   |+---------------+----------------+-----------+------------+---------+| test.a_br     | 0.4625M        | 0.0259G   | 0.0171G    | 0.0431G || test.a_skuclr | 0.7099M        | 0.0660G   | 0.0259G    | 0.0919G || test.a_yuser  | 1.0736M        | 0.0497G   | 0.0213G    | 0.0710G || test.test     | 0.0000M        | 0.0000G   | 0.0000G    | 0.0000G |+---------------+----------------+-----------+------------+---------+4 rows in set (0.13 sec)

 

[轉]【mysql監控】查看mysql庫大小,表大小,索引大小

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.