MySQL / MariaDB granular row size

Posted on

Question :

Is it possible in MySQL / MariaDB to calculate row size like in PostgreSQL ?
I’m looking to calculate in a multi tenant application how much space did the user use for the database but I couldn’t find anything relevant about this.

Answer :

In phpmyadmin you see the size of every table at the end . after you select a database.

if you want to do this in a query do, you need only the put in your own database name instead of testdb

SELECT SUM(Table_Size_MB) 'database_size_MB'
        (SELECT table_name AS "Table",
        ROUND(((data_length + index_length + DATA_FREE) / 1024 / 1024), 2) AS "Table_Size_MB"
        FROM information_schema.TABLES
        WHERE table_schema = "testdb"
        ORDER BY (data_length + index_length) DESC) tablessizes;

Leave a Reply

Your email address will not be published.