Heroku Data Labs: WAL Compression for Postgres Add-ons
Last updated November 02, 2022
Table of Contents
Write-Ahead Log (WAL) compression is a feature of Postgres databases that shrinks the size of write-ahead logs in your Postgres database. This compression trades off I/O load on your database for increased CPU load. You can enable this feature on your Heroku Postgres add-on with Heroku Data Labs.
The benefit of WAL compression on your database is dependent on a variety of factors including how your database is used, the amount of used disk space, and if your database has followers. Make sure to monitor your database to understand if WAL compression is right for you.
Features added through Heroku Data Labs are experimental and subject to change.
Enable WAL Compression
$ heroku data:labs:enable wal-compression --addon=YOUR_ADDON_NAME Enabling wal-compression on YOUR_ADDON_NAME...... done
Disable WAL Compression
$ heroku data:labs:disable wal-compression --addon=YOUR_ADDON_NAME Disabling wal-compression on YOUR_ADDON_NAME...... done
Applying these changes can take some time. If you receive an error saying the previous configuration is still in progress, try again later.
$ heroku data:labs:list --addon=YOUR_ADDON_NAME === Experimental Features Available for YOUR_ADDON_NAME: [+] wal-compression Write-ahead log compression on Heroku Postgres addons
A green cross within the box indicates that the WAL compression feature is enabled on your add-on, while an empty box indicates that it’s disabled.
Impact of WAL Compression on Your Database
Enabling WAL compression can reduce the wal-percentage-used metric for your database. Keeping this metric below 75% prevents the throttling of database connection limits. If this metric remains high even after enabling WAL compression, see Reduce WAL Generation for more tips.
While enabling this feature is beneficial to most databases, it can create unnecessary CPU load on some databases. Monitor your database performance to determine the impact of enabling this feature. Ensure that your CPU load stays below 1.0. See Heroku Postgres Monitoring for more info.