Contents
pg_column_compression()
A function returning the compression algorithm used on a TOAST value
pg_column_compression()
is a system function returning the compression algorithm used to compress a TOAST value.
pg_column_compression()
was added in PostgreSQL 14.
Usage
pg_column_compression ( "any" ) → text
If a value was not compressed, NULL
is returned.
Change history
- PostgreSQL 14
- added (commit bbe0a81d)
Examples
Example of pg_column_compression()
, with a value where no compression took place, a value which was compressed with the default pglz
algorithm, and a column compressed with lz4
:
postgres=# CREATE TABLE foo (id INT, val TEXT); CREATE TABLE postgres=# INSERT INTO foo values (1, 'bar'); INSERT 0 1 postgres=# INSERT INTO foo values (2, REPEAT('bar', 3072)); INSERT 0 1 postgres=# ALTER TABLE foo ALTER COLUMN val SET COMPRESSION lz4; ALTER TABLE postgres=# INSERT INTO foo values (3, REPEAT('baz', 3072)); INSERT 0 1 postgres=# SELECT id, pg_column_compression(val) FROM foo; id | pg_column_compression ----+----------------------- 1 | 2 | pglz 3 | lz4 (3 rows)
References
- PostgreSQL 14 documentation: Database Object Management Functions