As you know there is a great toolset named “MySQL Utilities”, which you can use for solving
various administrative tasks.
mysqldiskusage utility is for calculating MySQL Server’s disk usage and generating informative reports.
Of course this project is open source and everybody could review the source code.
A few words about how mysqldiskusage calculates database disk usage will be crucial for understanding algorithm.
The source tree is: mysql-utilities-1.5.4/scripts/mysqldiskusage.py
If you open this Python file you will …