pg_squeeze
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pg_squeeze | 1.9.1 | ADMIN | BSD 2-Clause | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 5040 | pg_squeeze | No | Yes | Yes | Yes | No | No | squeeze |
| Related | pg_repack pgfincore pg_prewarm pgstattuple pg_cooldown pgcozy amcheck pageinspect |
|---|
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PGDG | 1.9.1 | 1817161514 | pg_squeeze | - |
| RPM | PGDG | 1.9.1 | 1817161514 | pg_squeeze_$v | - |
| DEB | PGDG | 1.9.1 | 1817161514 | postgresql-$v-squeeze | - |
Install
You can install pg_squeeze directly. First, make sure the PGDG repository is added and enabled:
pig repo add pgdg -u # Add PGDG repo and update cache
Install the extension using pig or apt/yum/dnf:
pig install pg_squeeze; # Install for current active PG version
pig ext install -y pg_squeeze -v 18 # PG 18
pig ext install -y pg_squeeze -v 17 # PG 17
pig ext install -y pg_squeeze -v 16 # PG 16
pig ext install -y pg_squeeze -v 15 # PG 15
pig ext install -y pg_squeeze -v 14 # PG 14
dnf install -y pg_squeeze_18 # PG 18
dnf install -y pg_squeeze_17 # PG 17
dnf install -y pg_squeeze_16 # PG 16
dnf install -y pg_squeeze_15 # PG 15
dnf install -y pg_squeeze_14 # PG 14
apt install -y postgresql-18-squeeze # PG 18
apt install -y postgresql-17-squeeze # PG 17
apt install -y postgresql-16-squeeze # PG 16
apt install -y postgresql-15-squeeze # PG 15
apt install -y postgresql-14-squeeze # PG 14
Preload:
shared_preload_libraries = 'pg_squeeze';
Create Extension:
CREATE EXTENSION pg_squeeze;
Usage
pg_squeeze requires wal_level = logical and must be added to shared_preload_libraries. It removes bloat from tables while allowing concurrent reads and writes, using logical decoding instead of triggers.
Register a Table for Scheduled Processing
Insert into squeeze.tables to enable periodic bloat checks:
INSERT INTO squeeze.tables (tabschema, tabname, schedule)
VALUES ('public', 'foo', ('{30}', '{22}', NULL, NULL, '{3, 5}'));
The schedule field uses a crontab-like format: (minutes, hours, days_of_month, months, days_of_week). The above checks table foo every Wednesday and Friday at 22:30.
Optional columns: free_space_extra (min % extra free space to trigger, default 50), min_size (min MB, default 8), vacuum_max_age (max time since last VACUUM, default 1h), max_retry (retry count, default 0), clustering_index (sort tuples by this index), rel_tablespace, ind_tablespaces, skip_analyze.
Ad-hoc Squeeze
SELECT squeeze.squeeze_table('public', 'pgbench_accounts');
SELECT squeeze.squeeze_table('public', 'mytable', 'my_cluster_idx', 'target_tablespace');
Start / Stop Workers
SELECT squeeze.start_worker(); -- start scheduler + squeeze workers
SELECT squeeze.stop_worker(); -- stop all workers for current database
Auto-start on cluster boot via postgresql.conf:
squeeze.worker_autostart = 'my_database your_database'
squeeze.worker_role = postgres
Monitoring
squeeze.log– one entry per successfully squeezed table (withstarted,finished,ins_initial,ins,upd,del)squeeze.errors– errors during squeezingsqueeze.get_active_workers()– shows currently active squeeze workers and their progress
Configuration
squeeze.max_xlock_time– max exclusive lock time in ms (default unlimited)squeeze.workers_per_database– number of concurrent squeeze workers (default 1)
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.