A google search happened to land me in the Workload Tuning section of the OpenZFS wiki, which I generally avoid because I don’t know how up-to-date it is, and it’s generally geared towards we-do-this-for-money micro-optimizations for people who really know what they’re doing in production. It can be confusing and it’s not always clear whether certain recommendations are assuming you’re using ZFS in a way that volbocksize or recordsize is the controlling attribute.
Anyway, I don’t remember the recommendations for databases being this complex: Workload Tuning — OpenZFS documentation
MySQL
InnoDB
Make separate datasets for InnoDB’s data files and log files. Set
recordsize=16Kon InnoDB’s data files to avoid expensive partial record writes and leave recordsize=128K on the log files. Setprimarycache=metadataon both to prefer InnoDB’s caching 4. Setlogbias=throughputon the data to stop ZIL from writing twice.Set
innodb_doublewrite=0in my.cnf to prevent innodb from writing twice. The double writes are a data integrity feature meant to protect against corruption from partially-written records, but those are not possible on ZFS. It should be noted that Percona’s blog had advocated using an ext4 configuration where double writes were turned off for a performance gain, but later recanted it because it caused data corruption. Following a well timed power failure, an in place filesystem such as ext4 can have half of a 8KB record be old while the other half would be new. This would be the corruption that caused Percona to recant its advice. However, ZFS’ copy on write design would cause it to return the old correct data following a power failure (no matter what the timing is). That prevents the corruption that the double write feature is intended to prevent from ever happening. The double write feature is therefore unnecessary on ZFS and can be safely turned off for better performance.On Linux, the driver’s AIO implementation is a compatibility shim that just barely passes the POSIX standard. InnoDB performance suffers when using its default AIO codepath. Set
innodb_use_native_aio=0andinnodb_use_atomic_writes=0in my.cnf to disable AIO. Both of these settings must be disabled to disable AIO.
There’s a lot more there for InnoDB than I remember, and I’ve also been advised by more than one professional ZFS-based DB admin to use recordsize=1M for the log files.
While I’m interested in how up-to-date those recommendations (and the recommendations for SQL Lite and other specific workloads) are, it’s the Postgres rec that caught my attention.
PostgreSQL
Make separate datasets for PostgreSQL’s data and WAL. Set
compression=lz4andrecordsize=32K(64K also work well, as does the 128K default) on both. Previous advice beforecompression=lz4was to to setrecordsize=8Kto match PostgreSQL’s 8K page size to avoid write amplification, but compression often causes even bigger performance improvements 1, and compression is only effective when given largerrecordesize.Configure
full_page_writes = offfor PostgreSQL, as ZFS will never commit a partial write. But do not do this if you setrecordsize< 8K for some reason, or if there is any chance that somebody may copy this database config to a non-ZFS system, as PostgreSQL can end up with corrupt data on power loss if the filesystem does not provide at least Postgres-page-sized atomic writes 2.For a database with large updates, experiment with
logbias=throughputon PostgreSQL’s data to avoid writing twice, but be aware that with this setting smaller updates can cause severe fragmentation.
I’ve been to the Workload Tuning page multiple times (and ran away each time because it’s clearly written for people who know much more about micro-optimizing ZFS than I do and it confused the crap out of me–I’m much more confident with the advice and mentoring I’ve gotten here
).
But I don’t ever remember seeing that bolded part.
LZ4, compression ON has been the default in every install of ZFS I’ve used (Proxmox and TrueNAS) since at least 2020, and I’ve always seen guides say, with no ambiguity, to store Postgres database data with recordsize=8k, full stop. That’s also the advice I’ve seen repeated here. I don’t ever recall seeing LZ4 mentioned as a reason to deviate from that.
So, a couple of questions.
- In 2026, How trustworthy/worthwhile is the advice on the Workload Tuning page in general? I still feel like it’s very overcomplicated. And the advice there for BitTorrent, for example, doesn’t match the advice here at all: ZFS Performance Tuning for BitTorrent
- Is the Postgres advice in particular legit? (Or at least, is it worth paying attention to at the consumer/hobbyist/homelab ZFS level?)