pg_squeeze
pg_squeeze : A tool to remove unused space from a relation.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 5040 | pg_squeeze
|
pg_squeeze
|
1.9.1 |
ADMIN
|
BSD 2-Clause
|
C
|
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
--sLd--
|
No
|
Yes
|
Yes
|
Yes
|
no
|
no
|
| Relationships | |
|---|---|
| Schemas | squeeze |
| See Also | pg_repack
pgfincore
pg_prewarm
pgstattuple
pg_cooldown
pgcozy
amcheck
pageinspect
|
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PGDG
|
1.9.1 |
18
17
16
15
14
|
pg_squeeze |
- |
| RPM | PGDG
|
1.9.1 |
18
17
16
15
14
|
pg_squeeze_$v |
- |
| DEB | PGDG
|
1.9.1 |
18
17
16
15
14
|
postgresql-$v-squeeze |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
el8.x86_64
|
PGDG 1.9.1
|
PGDG 1.9.1
|
PGDG 1.9.1
|
PGDG 1.9.1
|
PGDG 1.9.1
|
el8.aarch64
|
PGDG 1.9.1
|
PGDG 1.9.1
|
PGDG 1.9.1
|
PGDG 1.9.1
|
PGDG 1.9.1
|
el9.x86_64
|
PGDG 1.9.1
|
PGDG 1.9.1
|
PGDG 1.9.1
|
PGDG 1.9.1
|
PGDG 1.9.1
|
el9.aarch64
|
PGDG 1.9.1
|
PGDG 1.9.1
|
PGDG 1.9.1
|
PGDG 1.9.1
|
PGDG 1.9.1
|
el10.x86_64
|
PGDG 1.9.1
|
PGDG 1.9.1
|
PGDG 1.9.1
|
PGDG 1.9.1
|
PGDG 1.9.1
|
el10.aarch64
|
PGDG 1.9.1
|
PGDG 1.9.1
|
PGDG 1.9.1
|
PGDG 1.9.1
|
PGDG 1.9.1
|
d12.x86_64
|
PGDG 1.9.1
|
PGDG 1.9.1
|
PGDG 1.9.1
|
PGDG 1.9.1
|
PGDG 1.9.1
|
d12.aarch64
|
PGDG 1.9.1
|
PGDG 1.9.1
|
PGDG 1.9.1
|
PGDG 1.9.1
|
PGDG 1.9.1
|
d13.x86_64
|
PGDG 1.9.1
|
PGDG 1.9.1
|
PGDG 1.9.1
|
PGDG 1.9.1
|
PGDG 1.9.1
|
d13.aarch64
|
PGDG 1.9.1
|
PGDG 1.9.1
|
PGDG 1.9.1
|
PGDG 1.9.1
|
PGDG 1.9.1
|
u22.x86_64
|
PGDG 1.9.1
|
PGDG 1.9.1
|
PGDG 1.9.1
|
PGDG 1.9.1
|
PGDG 1.9.1
|
u22.aarch64
|
PGDG 1.9.1
|
PGDG 1.9.1
|
PGDG 1.9.1
|
PGDG 1.9.1
|
PGDG 1.9.1
|
u24.x86_64
|
PGDG 1.9.1
|
PGDG 1.9.1
|
PGDG 1.9.1
|
PGDG 1.9.1
|
PGDG 1.9.1
|
u24.aarch64
|
PGDG 1.9.1
|
PGDG 1.9.1
|
PGDG 1.9.1
|
PGDG 1.9.1
|
PGDG 1.9.1
|
Source
Install
Make sure PGDG repo available:
pig repo add pgdg -u # add pgdg repo and update cacheInstall this extension with pig:
pig install pg_squeeze; # install via package name, for the active PG version
pig install pg_squeeze -v 18; # install for PG 18
pig install pg_squeeze -v 17; # install for PG 17
pig install pg_squeeze -v 16; # install for PG 16
pig install pg_squeeze -v 15; # install for PG 15
pig install pg_squeeze -v 14; # install for PG 14Config this extension to shared_preload_libraries:
shared_preload_libraries = 'pg_squeeze';Create this extension with:
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 databaseAuto-start on cluster boot via postgresql.conf:
squeeze.worker_autostart = 'my_database your_database'
squeeze.worker_role = postgresMonitoring
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)