Symptoms
- The size of database shown in Home > Domains > example.com > View More Statistics is significantly different from the size shown in Home > Domains > example. com > Databases tab > example_db
- The MySQL or MariaDB database uses the InnoDB engine
Cause
The cause is MySQL bug #1341 or MariaDB bug MDEV-14795 in which the ibdata (ibd) files grows as it keeps the information about data even after it was deleted from the database.
The difference in file size is expected for MySQL and MariaDB databases using InnoDB storage engine, because the size in Databases tab is taken from the information_schema
table, which is the real size of the database itself and View More Statistics shows the actual size of the /var/lib/mysql/example_db/
directory in the file system:
# du -sh /var/lib/mysql/example_db/
269M /var/lib/mysql/example_db/
Resolution
As a workaround, you need to optimize the MySQL database tables or optimize the MariaDB database tables manually, so that the unused space can be reclaimed.
Warning: During the optimization, the database will be inaccessible.