DB sizes.
authorOleksandr Gavenko <gavenkoa@gmail.com>
Fri, 22 Jan 2016 22:13:42 +0200
changeset 1878 25c0fb1dfc22
parent 1877 7627e51556bf
child 1879 b5f927fa28ce
DB sizes.
mysql.rst
--- a/mysql.rst	Fri Jan 22 22:10:18 2016 +0200
+++ b/mysql.rst	Fri Jan 22 22:13:42 2016 +0200
@@ -66,19 +66,27 @@
 
   MariaDB [mysql]> SHOW TABLE STATUS FROM mydb;
 
+::
+
   SELECT
-     table_schema as `Database`,
-     table_name AS `Table`,
-     round(((data_length + index_length) / 1024 / 1024), 2) `Size, MiB`
+    table_schema "Database",
+    ROUND(SUM(data_length+index_length)/1024/1024, 2) "Size, MiB"
+  FROM information_schema.TABLES
+  GROUP BY table_schema;
+
+  SELECT
+    table_schema as `Database`,
+    table_name AS `Table`,
+    round(((data_length + index_length) / 1024 / 1024), 2) `Size, MiB`
   FROM information_schema.TABLES
   ORDER BY (data_length + index_length) DESC;
 
   SELECT
-     table_schema as `Database`,
-     table_name AS `Table`,
-     round((data_length / 1024 / 1024), 2) `Data, MiB`,
-     round((index_length / 1024 / 1024), 2) `Index, MiB`,
-     round(((data_length+index_length) / 1024 / 1024), 2) `Total, MiB`
+    table_schema as `Database`,
+    table_name AS `Table`,
+    round((data_length / 1024 / 1024), 2) `Data, MiB`,
+    round((index_length / 1024 / 1024), 2) `Index, MiB`,
+    round(((data_length+index_length) / 1024 / 1024), 2) `Total, MiB`
   FROM information_schema.TABLES
   ORDER BY (data_length + index_length) DESC;