Tuesday, August 16, 2016

Database Size

Data Size/ Index Size/ Table Size
------------------------------------------
mysql> select table_name,
             round(data_length/1024/1024,2) "Data Size",
             round(index_length/1024/1024,2) "Index Size",
             round(data_length/1024/1024,2)+round(index_length/1024/1024,2) "Table Size"
             from information_schema.tables
             where table_schema='practice';
+----------------------------+-----------+------------+------------+
| table_name                 | Data Size | Index Size | Table Size |
+----------------------------+-----------+------------+------------+
| test1                      |      1.52 |       0.00 |       1.52 |
| test2                      |      0.14 |       0.00 |       0.14 |
| test3                      |    642.06 |     447.67 |    1089.73 |
| test4                      |    567.66 |     129.56 |     697.22 |
| test5                      |      0.02 |       0.02 |       0.04 |
| test6                      |      0.02 |       0.02 |       0.04 |
| test7                      |      0.02 |       0.00 |       0.02 |
+----------------------------+-----------+------------+------------+
7 rows in set (0.00 sec)

Database Size
------------------
mysql> select sum(round(data_length/1024/1024,2))+sum(round(index_length/1024/1024,2)) "DB Size" 
            from information_schema.tables
            where table_schema='practice';
+---------+
| DB Size |
+---------+
| 1788.71 |
+---------+
1 row in set (0.00 sec)

No comments:

Post a Comment