bzip

Bzip compression and decompression

Overview

PackageVersionCategoryLicenseLanguage
pg_bzip1.0.0UTILMITC
IDExtensionBinLibLoadCreateTrustRelocSchema
4020bzipNoYesNoYesNoNo-
Relatedgzip zstd http pg_net pg_curl pgjq pgjwt pg_smtp_client

Version

TypeRepoVersionPG VerPackageDeps
EXTPIGSTY1.0.01817161514pg_bzip-
RPMPIGSTY1.0.01817161514pg_bzip_$v-
DEBPIGSTY1.0.01817161514postgresql-$v-bzip-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64
el8.aarch64
el9.x86_64
el9.aarch64
el10.x86_64
el10.aarch64
d12.x86_64
d12.aarch64
d13.x86_64
d13.aarch64
u22.x86_64
u22.aarch64
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
u24.x86_64
u24.aarch64
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0

Build

You can build the RPM / DEB packages for pg_bzip using pig build:

pig build pkg pg_bzip         # build RPM / DEB packages

Install

You can install pg_bzip directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:

pig repo add pgsql -u          # Add repo and update cache

Install the extension using pig or apt/yum/dnf:

pig install pg_bzip;          # Install for current active PG version
pig ext install -y pg_bzip -v 18  # PG 18
pig ext install -y pg_bzip -v 17  # PG 17
pig ext install -y pg_bzip -v 16  # PG 16
pig ext install -y pg_bzip -v 15  # PG 15
pig ext install -y pg_bzip -v 14  # PG 14
dnf install -y pg_bzip_18       # PG 18
dnf install -y pg_bzip_17       # PG 17
dnf install -y pg_bzip_16       # PG 16
dnf install -y pg_bzip_15       # PG 15
dnf install -y pg_bzip_14       # PG 14
apt install -y postgresql-18-bzip   # PG 18
apt install -y postgresql-17-bzip   # PG 17
apt install -y postgresql-16-bzip   # PG 16
apt install -y postgresql-15-bzip   # PG 15
apt install -y postgresql-14-bzip   # PG 14

Create Extension:

CREATE EXTENSION bzip;

Usage

bzip: Bzip compression and decompression

Functions

  • bzcat(data bytea) returns bytea – Decompress bzip2 data, similar to the bzcat command.
  • bzip2(data bytea, compression_level int default 9) returns bytea – Compress data using bzip2.

Examples

Decompress a bzip2-compressed file:

SELECT convert_from(bzcat(pg_read_binary_file('/path/to/data.csv.bz2')), 'utf8') AS contents;

Compress data with bzip2:

SELECT bzip2(repeat('my text to be compressed', 1000)::bytea) AS compressed;

Compress with a custom compression level (1-9):

SELECT bzip2('some data'::bytea, 5);

Last Modified 2026-03-12: add pg extension catalog (95749bf)