TokuDB file & table sizes with information_schema
Here’s a few queries using the information_schema.TokuDB_fractal_tree_info to get the on disk size in MB for TokuDB tables.
This first one will sum up the on disk size for tables using the TokuDB engine.
SELECT table_schema, table_name, SUM(ROUND(bt_size_allocated / 1024 / 1024, 2)) AS table_size_mb
FROM information_schema.`TokuDB_fractal_tree_info`
WHERE table_schema = 'database_name'
GROUP BY table_schema, table_name;
To get a breakdown of the files making up a specific table run the following…
SELECT internal_file_name, SUM(ROUND(bt_size_allocated / 1024 / 1024, 2)) AS file_size_mb
FROM information_schema.`TokuDB_fractal_tree_info`
WHERE `table_schema` = 'database_name'
AND `table_name` = 'table_name'
GROUP BY internal_file_name
WITH ROLLUP
The figure might be slightly off the actual on disk size. I’ve never noticed a difference of more than 0.01% so it’s close enough for most purposes.