Speed Up Your PostgreSQL 16 Backups with Improved pg_dump

In PostgreSQL 16, pg_dump has become faster due to the introduction of new compression methods: LZ4 and ZSTD.

  • LZ4 Compression:
    • LZ4 is known for its high-speed compression and decompression.
    • While it may result in slightly larger file sizes compared to other methods, its speed makes it an attractive option for situations where time is a critical factor.
  • ZSTD Compression:
    • ZSTD, or Zstandard, offers a great balance between compression speed and file size reduction.
    • It has been observed that at the default compression level, ZSTD produces the smallest dump file size, followed by LZ4 and gzip.
    • In terms of time efficiency, ZSTD takes the least amount of time for compression, followed by LZ4 and gzip.

Example: When using pg_dump in PostgreSQL 16, you can specify the compression method:

  • For LZ4: pg_dump -F c -Z 1 -f dumpfile_lz4 dbname
  • For ZSTD: pg_dump -F c -Z 3 -f dumpfile_zstd dbname

Here, -F c specifies custom-format output, -Z specifies the compression level (1 for LZ4, 3 for ZSTD), and -f specifies the output file. The choice between LZ4 and ZSTD would depend on whether the priority is minimizing compression time (LZ4) or reducing dump file size (ZSTD).

About Shiv Iyer 446 Articles
Open Source Database Systems Engineer with a deep understanding of Optimizer Internals, Performance Engineering, Scalability and Data SRE. Shiv currently is the Founder, Investor, Board Member and CEO of multiple Database Systems Infrastructure Operations companies in the Transaction Processing Computing and ColumnStores ecosystem. He is also a frequent speaker in open source software conferences globally.