flate
pgflate · Raw DEFLATE compression and decompression functions for bytea
Overview
PostgreSQL · 10, 11, 12, 13, 14, 15, 16, 17, 18
Usage
Sources:
flate exposes zlib raw-DEFLATE compression and decompression for PostgreSQL bytea values. Version 1.0.1 is suitable when an application specifically needs raw streams; its output does not contain a zlib or gzip wrapper.
Core Workflow
deflate(bytea, bytea, integer) accepts optional preset-dictionary and compression-level arguments. inflate(bytea, bytea) must receive the same dictionary when one was used for compression:
A NULL level selects zlib’s default; explicit levels follow zlib’s 0 through 9 range. Both functions are declared immutable.
Operational Caveats
The dictionary is not embedded in the compressed value. A missing or different dictionary, damaged input, or a stream with the wrong wrapper format causes decompression to fail or produce unusable data.
Compressed input can expand to a much larger result. Limit untrusted input sizes and account for backend memory and statement timeout before calling inflate(bytea, bytea). Store the encoding, wrapper choice, and dictionary version alongside data so another client can reproduce the operation.