Reducing hubzilla's database to 30% when using Mariadb/MySQL
@!
Hubzilla Support Forum I've discovered something by coincidence - how to reduce Hubzllla's database without any information loss when using MariaDB or MySQL as a database backend.
I was moving the database to another host (got new ARM64 servers at Netcup) and I had a closer look at my database settings (and setting them via ansible when installing the new servers).
I've made some changes and discovered something impressive:InnoDB Page Compression (
https://mariadb.com/kb/en/innodb-page-compression/). I dumped my database on the old host and imported it into the new host, with page compression active.
Well, let's have a look at the results:
Old db host:
du -sh hub_netzgemeinde_eu
147G hub_netzgemeinde_eu
New db host after importing the dump:
du -sh hub_netzgemeinde_eu
46G hub_netzgemeinde_eu
Now,
that's what I call impressive :-) Not data loss, the information are identical - just nearly 70% space saved.
I'm using lz4 als compression algorithm and I have encounted no perfomance impact by doing so.
I'm using these settings:
innodb_compression_default = ON
innodb_compression_algorithm = lz4
However, lz4 is an additonal algorithm, standard are zlib and gzip. Depending on your distribution you may have to install the plugin and (in my case) set it up:
plugin_load_add = provider_lz4
There are two caveats:
1.) The filesyste should support sparse files, xfs, btrfs, ext3/4 work fine
2.) xtrabackup cannot cope with compressed pages, however mariadb-backup (which is the better choice anyway) has no problems with it.
Since I've dumped data into a freshly, empty mariadb (with thse settings), how about converting an existing one to page_compression?
I can only guess, but I think a
mariadb-check -o --all-databases
(or
mysqloptimize --all-databases
) would to the trick - it recreates (with no downtime) all tables and the newly created tables should have compression enabled, so this is also the way back if you don't like compression