Skip to main content

Switching from database to filesystem storage or back doesn't change database size - Knowledgebase / Deskpro Legacy - Deskpro Support

WARNING: You're browsing documentation for an older version of Deskpro. Consider upgrading to Deskpro Horizon

Switching from database to filesystem storage or back doesn't change database size

Authors list

Question:

In Server > File Uploads I switched Deskpro to use filesystem storage. I'd expect that moving all the attachments and so on from the database to the filesystem would decrease the size of the MySQL database.

However, the database size doesn't seem to have gone down. Is something wrong?

 

Answer:

The default behaviour for MySQL is that it never releases disk space. Unless you enable the innodb_file_per_table parameter when you first set up the server, it will keep disk space for future use after stored objects are deleted; as a result, the disk space used never decreases, only increases.

This also means that if you move from filesystem to database storage, the size of the database may not increase as much as you expect - MySQL may have reserved disk space that it is not using.

To find a better estimate of the size in MB of a particular table, use a query like this:

SELECT TABLE_NAME, table_rows, round(((data_length + index_length) / 1024 / 1024),2) size
FROM information_schema.TABLES 
WHERE table_schema = 'your_database_name' AND TABLE_TYPE='BASE TABLE' 
ORDER BY data_length DESC

Replace your_database_name with the name of your database. Binary objects, like images/attachments, are found in the blobs_storage table.

After switching to filesystem storage, you may want to reclaim disk space from MySQL by enabling innodb_file_per_table.

In MySQL 5.5 and higher, innodb_file_per_table is dynamic, and can be set ON or OFF using SET GLOBAL. Dynamically changing the value of this parameter requires the SUPER privilege and immediately affects the operation of all connections.

In older versions of MySQL, this parameter is set in the configuration file (my.cnf or my.ini). You must shut down and restart the database server for changes to take effect. (Note that we always recommend running the latest 5.x.x version).

Naudingas Nenaudingas

37 iš 63 žmonių mano, kad šis puslapis naudingas

Add a comment

Please log in or register to submit a comment.

Ar reikia priminti slaptažodį?