{"authors":["utzer"],"canonical_url":"https://newblog.utzer.de/2019/10/02/size-of-each-table-in-a-database-of-mysql-or-mariadb/","categories":["Linux","MariaDB"],"content":"I found something pretty useful, just a quick #MySQL / #MariaDB code snippet to show the size of each table of the currently selected database.\n\n```\nSELECT table_name ,\n  round(((data_length + index_length) / 1024 / 1024), 2) as SIZE_MB\nFROM information_schema.TABLES\nWHERE table_schema = DATABASE() ORDER BY SIZE_MB DESC;\n```\n\nYou have to start 'mysql' from CLI, in any terminal emulator of you choice, by adding the database name it should select when started, so lets say the database you're looking to get the table sizes from is 'wordpress' you'd have to call 'mysql wordpress' and then in mysql you'd have to enter the whole code snippet from above and hit enter afterwards.\n\nYou'll get a list of all tables ordered by their size, looking like this:\n\n```\n+---------------------------+---------+\n| table_name                | SIZE_MB |\n+---------------------------+---------+\n| item                      | 1656.30 |\n| item-body                 | 1166.86 |\n| terms                     | 1029.72 |\n| item-url                  |   11.89 |\n| conv                      |    1.17 |\n+---------------------------+---------+\n\n```\n\n[Source](https://stackoverflow.com/a/42262936/11544289)\n","content_format":"markdown","date":"2019-10-02T19:31:42Z","description":"I found something pretty useful, just a quick #MySQL / #MariaDB code snippet to show the size of each table of the currently selected database. ``` SELECT table_name , round(((data_length + index_length) / 1024 / 1024), 2) as SIZE_MB FROM information_schema.TABLES WHERE table_schema = DATABASE() ORD","html_url":"https://newblog.utzer.de/2019/10/02/size-of-each-table-in-a-database-of-mysql-or-mariadb/","json_url":"https://newblog.utzer.de/2019/10/02/size-of-each-table-in-a-database-of-mysql-or-mariadb/index.json","lastmod":"2019-10-02T19:31:42Z","markdown_url":"https://newblog.utzer.de/2019/10/02/size-of-each-table-in-a-database-of-mysql-or-mariadb/index.md","media":[],"schema_version":1,"tags":["MariaDB","MySQL","Terminal"],"title":"Size of each table in a database of MySQL or MariaDB","type":"blog_post"}