View all files | ||||
pgzstd is a PostgreSQL extension that provides functions for compressing and uncompressing Zstandard frames, with support for custom dictionaries.
Run make to build the extension.
Run make install as root (e.g. with sudo) to install the extension.
The repository also contains the files for building a Debian package, which can be done by running pg_buildext updatecontrol followed by dpkg-buildpackage. I distribute pre-built versions for stable amd64 Debian using the apt.postgresql.org repository in my personal APT repository. Run apt-get install postgresql-PGVERSION-zstd as root after setting up the repository.
Run CREATE EXTENSION zstd to install the extension in the current database. Three functions are provided:
| 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.
This project is available under the terms of the ISC license, which is similar to the 2-clause BSD license. See the LICENSE file for the copyright information and licensing terms.