I'm trying to get the space that a table using the MyRocks storage engine takes on disk and I'm getting inconsistent results between what I expect, a query on information_schema
and the size as reported by the OS.
To get the size as reported by MariaDB, I'm using the following select statement:
select table_name 'Table Name',
(data_length+index_length)/power(1024,3) 'Table Size in GB'
from information_schema.tables where table_schema="MyTableName";
Which returns a really small number for what I'm doing, to the point where I'm doubtful that it's reporting the actual size (0.4GB for 4 000 000 rows with a lot of text).
If I run the command du -h /var/lib/mysql/#rocksdb/
, I'm getting a disk size of 2.4GB, which is a bit more than what I would expect. However, if I understand correctly, MyRocks compacts data as data is inserted, so it's possible that the disk space reported by the du
command is unrepresentative of the actual table size.
So, is there a reliable method to get the size of a table? Am I already using the correct way to get the table size?