zstd
Module:
Categories:
Overview
PIGSTY 3rd Party Extension: pg_zstd : Zstandard compression algorithm implementation in PostgreSQL
Information
- Extension ID: 4030
- Extension Name:
zstd - Package Name:
pg_zstd - Category:
UTIL - License: ISC
- Website: https://github.com/grahamedgecombe/pgzstd
- Language: C
- Extra Tags: N/A
- Comment:
Metadata
- Latest Version: 1.1.2
- Postgres Support:
17,16,15,14,13 - Need Load: Shared library do not need explicit loading
- Need DDL: Need
CREATE EXTENSIONDDL - Relocatable: Can not install to arbitrary schema
- Trusted: Unknown
- Schemas: N/A
- Requires: N/A
RPM / DEB
- RPM Repo: PIGSTY
- RPM Name:
pg_zstd_$v* - RPM Ver :
1.1.2 - RPM Deps: N/A
- DEB Repo: PIGSTY
- DEB Name:
postgresql-$v-zstd - DEB Ver :
1.1.2 - DEB Deps: N/A
Availability
| OS | Arch | PG17 | PG16 | PG15 | PG14 | PG13 |
|---|---|---|---|---|---|---|
el8 |
x86_64 |
pg_zstd_17 PIGSTY 1.1.2 |
pg_zstd_16 PIGSTY 1.1.2 |
pg_zstd_15 PIGSTY 1.1.2 |
pg_zstd_14 PIGSTY 1.1.2 |
pg_zstd_13 PIGSTY 1.1.2 |
el8 |
aarch64 |
pg_zstd_17 PIGSTY 1.1.2 |
pg_zstd_16 PIGSTY 1.1.2 |
pg_zstd_15 PIGSTY 1.1.2 |
pg_zstd_14 PIGSTY 1.1.2 |
pg_zstd_13 PIGSTY 1.1.2 |
el9 |
x86_64 |
pg_zstd_17 PIGSTY 1.1.2 |
pg_zstd_16 PIGSTY 1.1.2 |
pg_zstd_15 PIGSTY 1.1.2 |
pg_zstd_14 PIGSTY 1.1.2 |
pg_zstd_13 PIGSTY 1.1.2 |
el9 |
aarch64 |
pg_zstd_17 PIGSTY 1.1.2 |
pg_zstd_16 PIGSTY 1.1.2 |
pg_zstd_15 PIGSTY 1.1.2 |
pg_zstd_14 PIGSTY 1.1.2 |
pg_zstd_13 PIGSTY 1.1.2 |
d12 |
x86_64 |
postgresql-17-zstd PIGSTY 1.1.2 |
postgresql-16-zstd PIGSTY 1.1.2 |
postgresql-15-zstd PIGSTY 1.1.2 |
postgresql-14-zstd PIGSTY 1.1.2 |
postgresql-13-zstd PIGSTY 1.1.2 |
d12 |
aarch64 |
postgresql-17-zstd PIGSTY 1.1.2 |
postgresql-16-zstd PIGSTY 1.1.2 |
postgresql-15-zstd PIGSTY 1.1.2 |
postgresql-14-zstd PIGSTY 1.1.2 |
postgresql-13-zstd PIGSTY 1.1.2 |
u22 |
x86_64 |
postgresql-17-zstd PIGSTY 1.1.2 |
postgresql-16-zstd PIGSTY 1.1.2 |
postgresql-15-zstd PIGSTY 1.1.2 |
postgresql-14-zstd PIGSTY 1.1.2 |
postgresql-13-zstd PIGSTY 1.1.2 |
u22 |
aarch64 |
postgresql-17-zstd PIGSTY 1.1.2 |
postgresql-16-zstd PIGSTY 1.1.2 |
postgresql-15-zstd PIGSTY 1.1.2 |
postgresql-14-zstd PIGSTY 1.1.2 |
postgresql-13-zstd PIGSTY 1.1.2 |
u24 |
x86_64 |
postgresql-17-zstd PIGSTY 1.1.2 |
postgresql-16-zstd PIGSTY 1.1.2 |
postgresql-15-zstd PIGSTY 1.1.2 |
postgresql-14-zstd PIGSTY 1.1.2 |
postgresql-13-zstd PIGSTY 1.1.2 |
u24 |
aarch64 |
postgresql-17-zstd PIGSTY 1.1.2 |
postgresql-16-zstd PIGSTY 1.1.2 |
postgresql-15-zstd PIGSTY 1.1.2 |
postgresql-14-zstd PIGSTY 1.1.2 |
postgresql-13-zstd PIGSTY 1.1.2 |
Installation
Install zstd via the pig CLI tool:
pig ext install pg_zstd; # Extension Name
pig ext install zstd; # normalized package name
Install pg_zstd via Pigsty playbook:
./pgsql.yml -t pg_extension -e '{"pg_extensions": ["pg_zstd"]}' # -l <cls>
Install pg_zstd RPM from YUM repo directly:
dnf install pg_zstd_17*;
dnf install pg_zstd_16*;
dnf install pg_zstd_15*;
dnf install pg_zstd_14*;
dnf install pg_zstd_13*;
Install pg_zstd DEB from APT repo directly:
apt install postgresql-17-zstd;
apt install postgresql-16-zstd;
apt install postgresql-15-zstd;
apt install postgresql-14-zstd;
apt install postgresql-13-zstd;
Create zstd extension on PostgreSQL cluster:
CREATE EXTENSION zstd;
Usage
| Function | Return Type |
|---|---|
zstd_compress(data bytea [, dictionary bytea [, level integer ]]) |
bytea |
zstd_decompress(data bytea [, dictionary bytea ]) |
bytea |
zstd_length(data bytea) |
integer |
zstd_compress compresses the provided data and returns a Zstandard frame. A
preset dictionary may also be provided. The default compression level may
also be overriden, valid values range from 1 (best speed) to 22 (best
compression). The default level is 3.
If you want to override the compression level without using a dictionary, set
dictionary to NULL.
zstd_decompress decompresses the provided Zstandard frame in data and
returns the uncompressed data. A preset dictionary, matching the dictionary
used to compress the data, may also be provided.
zstd_length returns the decompressed length of the provided Zstandard frame.
If ZSTD_getFrameContentSize() is available it returns NULL if the length is
unknown. If unavailable, it isn’t possible to distinguish the error, unknown
decompressed length and zero decompressed length cases.
Example
Basic compress/decompress example:
CREATE EXTENSION zstd;
SELECT zstd_compress('hello world');
-- zstd_compress
-- --------------------------------------------
-- \x28b52ffd200b59000068656c6c6f20776f726c64
SELECT convert_from(zstd_decompress('\x28b52ffd200b59000068656c6c6f20776f726c64'), 'utf-8');
-- convert_from
-- --------------
-- hello world
Compress with level (1 for best speed, 22 for best compression, default to 3)
CREATE EXTENSION zstd;
SELECT zstd_compress('hello world', NULL, 10);
-- zstd_compress
-- --------------------------------------------
-- \x28b52ffd200b59000068656c6c6f20776f726c64
SELECT convert_from(zstd_decompress('\x28b52ffd200b59000068656c6c6f20776f726c64'), 'utf-8');
-- convert_from
-- --------------
-- hello world
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.