compression_test
compression_test · Backend utilities for experimenting with PostgreSQL pglz compression
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 102059 | compression_test | compression_test | 1.0 | UTIL | PostgreSQL | C |
Usage
Sources:
compression_test 1.0 exposes backend utilities for experimenting with pglz compression and raw relation pages. It is a developer module from Michael Paquier’s plugin collection. The module README states PostgreSQL 9.5 onward, but it relies on server internals; verify the target major when building.
Core Workflow
Install as a superuser. A separate schema avoids collisions with the module’s generic function names:
This compares byte counts only. Compression returns the original bytes when the algorithm cannot compress them; the result carries no flag distinguishing that case. Keep the original bytes and length and do not treat every output as a decompressible frame.
Function Index
compress_data(bytea)uses the built-in always-try pglz strategy. Its seven-argument overload also accepts minimum and maximum input sizes, minimum compression rate, first-success threshold and two match-search controls. These are low-level experiment settings.decompress_data(bytea, smallint)needs the original uncompressed length as its second argument. The declared type limits that length to a positive signed 16-bit value. Invalid or incompressible input can fail; this is not a self-describing archive format.bytea_size(bytea)returns payload bytes, excluding the varlena header.get_raw_page(oid, int4, bool)returns page bytes and a hole offset. It checks superuser privilege. A false final argument removes the page’s free-space hole; a true argument preserves a full page. Do not rely on that branch to sanitize unused bytes: the current implementation clears its local buffer after copying the returned page.
Boundaries
Raw pages expose physical storage contents, not MVCC-filtered query results. Use only controlled test data and retain the schema’s access restrictions. These helpers neither enable table compression nor define a stable, portable persistence format. They do not require a background worker or preloading.