Best Way to compress mysqldump?

MySQLMySQLi Database

The compression operation is used only if both client and server support ‘zlib’ compression, and the client requests compression.

Usage of mysqldump

  • The advantage of using compression is that it reduces the size of the payload

  • On the other hand, the disadvantage of using compression is that it increases the computation time.

  • Performance benefits will depend largely on the size of the result set which is being sent.

  • In addition to this, the network bandwidth and latency between the database server and its clients also matters. The larger the result set, the larger will be the latency.

  • In other words, the lesser the bandwidth, the more likely the user would see the benefit of compression.

The maximum level of service is limited to the smallest bottleneck. Hence, it is required to analyse the position regarding network and CPU resources in the current time.

The most optimized database server would utilize 100% of its CPU 100% of the time, otherwise the computing resources get wasted if it has a processor that is sitting idle.

A table can be rebuilt by dumping and reloading it. This can be done by using the ‘mysqldump’ and creating a dump file and allowing mysql to reload the file. This can be done using the below commands −

mysqldump db_name t1 > dump.sql
mysql db_name < dump.sql

If the user has a large mysqldump file, and they wish to import it from one system using FTP to another, without having to spend more time on it, it can be done using the below command

mysqldump −u root −p database_name | gzip > dump.gz

Another way is to zip the contents of the file, but this wouldn’t be considered the best way.

raja
Published on 10-Mar-2021 16:23:50
Advertisements