B3archiveNote19 November 20252-minute read

What zstd's compression levels actually cost

XtraBackup Manager compresses every MySQL backup with zstd at level 1, on four threads. It's the lowest level, and the obvious question is why I didn't turn it up.

zstd's levels trade time for size. The higher levels squeeze out more, but the time climbs much faster than the savings. For a backup that runs every night, the time is a cost you pay every night. The space you save, you collect slowly.

The other half is decompression, and it's the half people forget to think about. zstd decompresses at roughly the same speed whatever level you compressed at, so the level mostly changes how long the backup takes, not how long the restore takes.

The restore pays in a different way. A compressed XtraBackup backup has to be decompressed before it can be prepared, so my tool copies the backup and decompresses it first, and it checks for twice the backup's size in free space before it starts. The space you saved in the archive comes back as space you need on restore day, which is exactly the day you don't want a full disk.

So the real questions aren't about the level. How long is your backup window? How many weeks do you keep? How much free disk will the restore machine have on its worst day? For a nightly backup of a busy database, level 1 with a few threads is where I start. If the archive gets tight, raising the level is a cheap experiment, because the restore won't get any slower.

Ring the bell

Got a question one of these didn't answer? Ask me directly.

Get in touch