Using data compression
As data volumes expand, we often think about whether there are ways to compress data to save space. There are many patents awarded in data compression, so the development of open source solutions has been slower than normal. PostgreSQL 14 contains some exciting innovations.
Getting ready
Make sure you're running Postgres 14+.
Various types of data compression are available for PostgreSQL:
- Automatic compression of long data values (
TOAST
) - Extensions that offer compressed data types (for example, for JSON)
- Compression of WAL files
- Dump file compression
- Base backup compression
- SSL compression (this is considered insecure, so it's only used on private networks)
- GiST and SP-GiST index compression
- Btree index compression (also known as deduplication)
Only the first three types of compression will be discussed here, but we focus mainly on the parameters that allow us to control how long data values are automatically...