Skip to content
pg_squeeze

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.4
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
pgstattuple
pg_dirtyread
pg_rewrite
pg_column_tetris

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT
PGDG
1.9.4
18
17
16
15
14
pg_squeeze -
RPM
PGDG
1.9.4
18
17
16
15
14
pg_squeeze_$v -
DEB
PGDG
1.9.4
18
17
16
15
14
postgresql-$v-squeeze -
Linux / PG PG18 PG17 PG16 PG15 PG14
el8.x86_64
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
el8.aarch64
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
el9.x86_64
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
el9.aarch64
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
el10.x86_64
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
el10.aarch64
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
d12.x86_64
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
d12.aarch64
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
d13.x86_64
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
d13.aarch64
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
u22.x86_64
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
u22.aarch64
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
u24.x86_64
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
u24.aarch64
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
u26.x86_64
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
u26.aarch64
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
PGDG 1.9.4
Package Version OS ORG SIZE File URL
pg_squeeze_18 1.9.4 el8.x86_64 pgdg 58.6 KiB pg_squeeze_18-1.9.4-1PGDG.rhel8.10.x86_64.rpm
pg_squeeze_18 1.9.2 el8.x86_64 pgdg 58.2 KiB pg_squeeze_18-1.9.2-1PGDG.rhel8.10.x86_64.rpm
pg_squeeze_18 1.9.1 el8.x86_64 pgdg 57.6 KiB pg_squeeze_18-1.9.1-1PGDG.rhel8.x86_64.rpm
pg_squeeze_18 1.9.4 el8.aarch64 pgdg 55.8 KiB pg_squeeze_18-1.9.4-1PGDG.rhel8.10.aarch64.rpm
pg_squeeze_18 1.9.2 el8.aarch64 pgdg 55.4 KiB pg_squeeze_18-1.9.2-1PGDG.rhel8.10.aarch64.rpm
pg_squeeze_18 1.9.1 el8.aarch64 pgdg 54.8 KiB pg_squeeze_18-1.9.1-1PGDG.rhel8.aarch64.rpm
pg_squeeze_18 1.9.4 el9.x86_64 pgdg 57.3 KiB pg_squeeze_18-1.9.4-1PGDG.rhel9.8.x86_64.rpm
pg_squeeze_18 1.9.2 el9.x86_64 pgdg 57.0 KiB pg_squeeze_18-1.9.2-1PGDG.rhel9.8.x86_64.rpm
pg_squeeze_18 1.9.2 el9.x86_64 pgdg 56.8 KiB pg_squeeze_18-1.9.2-1PGDG.rhel9.7.x86_64.rpm
pg_squeeze_18 1.9.2 el9.x86_64 pgdg 57.2 KiB pg_squeeze_18-1.9.2-1PGDG.rhel9.6.x86_64.rpm
pg_squeeze_18 1.9.1 el9.x86_64 pgdg 56.8 KiB pg_squeeze_18-1.9.1-3PGDG.rhel9.8.x86_64.rpm
pg_squeeze_18 1.9.1 el9.x86_64 pgdg 56.6 KiB pg_squeeze_18-1.9.1-1PGDG.rhel9.x86_64.rpm
pg_squeeze_18 1.9.4 el9.aarch64 pgdg 55.6 KiB pg_squeeze_18-1.9.4-1PGDG.rhel9.8.aarch64.rpm
pg_squeeze_18 1.9.2 el9.aarch64 pgdg 55.3 KiB pg_squeeze_18-1.9.2-1PGDG.rhel9.8.aarch64.rpm
pg_squeeze_18 1.9.2 el9.aarch64 pgdg 55.3 KiB pg_squeeze_18-1.9.2-1PGDG.rhel9.7.aarch64.rpm
pg_squeeze_18 1.9.2 el9.aarch64 pgdg 55.4 KiB pg_squeeze_18-1.9.2-1PGDG.rhel9.6.aarch64.rpm
pg_squeeze_18 1.9.1 el9.aarch64 pgdg 54.9 KiB pg_squeeze_18-1.9.1-3PGDG.rhel9.8.aarch64.rpm
pg_squeeze_18 1.9.1 el9.aarch64 pgdg 54.6 KiB pg_squeeze_18-1.9.1-1PGDG.rhel9.aarch64.rpm
pg_squeeze_18 1.9.4 el10.x86_64 pgdg 57.6 KiB pg_squeeze_18-1.9.4-1PGDG.rhel10.2.x86_64.rpm
pg_squeeze_18 1.9.2 el10.x86_64 pgdg 57.3 KiB pg_squeeze_18-1.9.2-1PGDG.rhel10.2.x86_64.rpm
pg_squeeze_18 1.9.2 el10.x86_64 pgdg 57.3 KiB pg_squeeze_18-1.9.2-1PGDG.rhel10.1.x86_64.rpm
pg_squeeze_18 1.9.2 el10.x86_64 pgdg 57.7 KiB pg_squeeze_18-1.9.2-1PGDG.rhel10.0.x86_64.rpm
pg_squeeze_18 1.9.1 el10.x86_64 pgdg 57.0 KiB pg_squeeze_18-1.9.1-3PGDG.rhel10.2.x86_64.rpm
pg_squeeze_18 1.9.1 el10.x86_64 pgdg 57.1 KiB pg_squeeze_18-1.9.1-1PGDG.rhel10.x86_64.rpm
pg_squeeze_18 1.9.4 el10.aarch64 pgdg 56.0 KiB pg_squeeze_18-1.9.4-1PGDG.rhel10.2.aarch64.rpm
pg_squeeze_18 1.9.2 el10.aarch64 pgdg 55.7 KiB pg_squeeze_18-1.9.2-1PGDG.rhel10.2.aarch64.rpm
pg_squeeze_18 1.9.2 el10.aarch64 pgdg 55.7 KiB pg_squeeze_18-1.9.2-1PGDG.rhel10.1.aarch64.rpm
pg_squeeze_18 1.9.2 el10.aarch64 pgdg 55.7 KiB pg_squeeze_18-1.9.2-1PGDG.rhel10.0.aarch64.rpm
pg_squeeze_18 1.9.1 el10.aarch64 pgdg 55.3 KiB pg_squeeze_18-1.9.1-3PGDG.rhel10.2.aarch64.rpm
pg_squeeze_18 1.9.1 el10.aarch64 pgdg 55.6 KiB pg_squeeze_18-1.9.1-1PGDG.rhel10.aarch64.rpm
postgresql-18-squeeze 1.9.4 d12.x86_64 pgdg 116.4 KiB postgresql-18-squeeze_1.9.4-2.pgdg12+1_amd64.deb
postgresql-18-squeeze 1.9.4 d12.x86_64 pgdg 116.3 KiB postgresql-18-squeeze_1.9.4-1.pgdg12+1_amd64.deb
postgresql-18-squeeze 1.9.3 d12.x86_64 pgdg 116.2 KiB postgresql-18-squeeze_1.9.3-1.pgdg12+1_amd64.deb
postgresql-18-squeeze 1.9.4 d12.aarch64 pgdg 112.1 KiB postgresql-18-squeeze_1.9.4-2.pgdg12+1_arm64.deb
postgresql-18-squeeze 1.9.4 d12.aarch64 pgdg 111.9 KiB postgresql-18-squeeze_1.9.4-1.pgdg12+1_arm64.deb
postgresql-18-squeeze 1.9.3 d12.aarch64 pgdg 111.8 KiB postgresql-18-squeeze_1.9.3-1.pgdg12+1_arm64.deb
postgresql-18-squeeze 1.9.4 d13.x86_64 pgdg 116.8 KiB postgresql-18-squeeze_1.9.4-2.pgdg13+1_amd64.deb
postgresql-18-squeeze 1.9.4 d13.x86_64 pgdg 116.9 KiB postgresql-18-squeeze_1.9.4-1.pgdg13+1_amd64.deb
postgresql-18-squeeze 1.9.3 d13.x86_64 pgdg 116.6 KiB postgresql-18-squeeze_1.9.3-1.pgdg13+1_amd64.deb
postgresql-18-squeeze 1.9.4 d13.aarch64 pgdg 112.1 KiB postgresql-18-squeeze_1.9.4-2.pgdg13+1_arm64.deb
postgresql-18-squeeze 1.9.4 d13.aarch64 pgdg 112.0 KiB postgresql-18-squeeze_1.9.4-1.pgdg13+1_arm64.deb
postgresql-18-squeeze 1.9.3 d13.aarch64 pgdg 111.9 KiB postgresql-18-squeeze_1.9.3-1.pgdg13+1_arm64.deb
postgresql-18-squeeze 1.9.4 u22.x86_64 pgdg 119.3 KiB postgresql-18-squeeze_1.9.4-2.pgdg22.04+1_amd64.deb
postgresql-18-squeeze 1.9.4 u22.x86_64 pgdg 119.6 KiB postgresql-18-squeeze_1.9.4-1.pgdg22.04+1_amd64.deb
postgresql-18-squeeze 1.9.3 u22.x86_64 pgdg 119.0 KiB postgresql-18-squeeze_1.9.3-1.pgdg22.04+1_amd64.deb
postgresql-18-squeeze 1.9.4 u22.aarch64 pgdg 114.2 KiB postgresql-18-squeeze_1.9.4-2.pgdg22.04+1_arm64.deb
postgresql-18-squeeze 1.9.4 u22.aarch64 pgdg 114.2 KiB postgresql-18-squeeze_1.9.4-1.pgdg22.04+1_arm64.deb
postgresql-18-squeeze 1.9.3 u22.aarch64 pgdg 113.9 KiB postgresql-18-squeeze_1.9.3-1.pgdg22.04+1_arm64.deb
postgresql-18-squeeze 1.9.4 u24.x86_64 pgdg 116.3 KiB postgresql-18-squeeze_1.9.4-2.pgdg24.04+1_amd64.deb
postgresql-18-squeeze 1.9.4 u24.x86_64 pgdg 116.1 KiB postgresql-18-squeeze_1.9.4-1.pgdg24.04+1_amd64.deb
postgresql-18-squeeze 1.9.3 u24.x86_64 pgdg 116.2 KiB postgresql-18-squeeze_1.9.3-1.pgdg24.04+1_amd64.deb
postgresql-18-squeeze 1.9.4 u24.aarch64 pgdg 111.7 KiB postgresql-18-squeeze_1.9.4-2.pgdg24.04+1_arm64.deb
postgresql-18-squeeze 1.9.4 u24.aarch64 pgdg 111.7 KiB postgresql-18-squeeze_1.9.4-1.pgdg24.04+1_arm64.deb
postgresql-18-squeeze 1.9.3 u24.aarch64 pgdg 111.7 KiB postgresql-18-squeeze_1.9.3-1.pgdg24.04+1_arm64.deb
postgresql-18-squeeze 1.9.4 u26.x86_64 pgdg 114.9 KiB postgresql-18-squeeze_1.9.4-2.pgdg26.04+1_amd64.deb
postgresql-18-squeeze 1.9.4 u26.x86_64 pgdg 114.9 KiB postgresql-18-squeeze_1.9.4-1.pgdg26.04+1_amd64.deb
postgresql-18-squeeze 1.9.3 u26.x86_64 pgdg 114.6 KiB postgresql-18-squeeze_1.9.3-1.pgdg26.04+1_amd64.deb
postgresql-18-squeeze 1.9.4 u26.aarch64 pgdg 110.5 KiB postgresql-18-squeeze_1.9.4-2.pgdg26.04+1_arm64.deb
postgresql-18-squeeze 1.9.4 u26.aarch64 pgdg 110.2 KiB postgresql-18-squeeze_1.9.4-1.pgdg26.04+1_arm64.deb
postgresql-18-squeeze 1.9.3 u26.aarch64 pgdg 110.3 KiB postgresql-18-squeeze_1.9.3-1.pgdg26.04+1_arm64.deb

Source

Install

Make sure PGDG repo available:

pig repo add pgdg -u    # add pgdg repo and update cache

Install 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 14

Config this extension to shared_preload_libraries:

shared_preload_libraries = 'pg_squeeze';

Create this extension with:

CREATE EXTENSION pg_squeeze;

Usage

Sources:

pg_squeeze removes bloat from a table and its indexes while allowing concurrent reads and writes. It copies live tuples to new storage and applies concurrent changes through logical decoding, avoiding the long exclusive lock of VACUUM FULL. Use it only after sizing replication slots, disk space, and the table’s replica identity.

Configure and Install

max_replication_slots = 1  # or add one to the existing requirement
shared_preload_libraries = 'pg_squeeze'
wal_level = logical       # required on PostgreSQL versions before 19

Restart PostgreSQL, then create the extension:

CREATE EXTENSION pg_squeeze;

The table must have an identity index. A primary key works with the default replica identity; otherwise select a suitable unique index with ALTER TABLE ... REPLICA IDENTITY USING INDEX.

Run an Ad-Hoc Squeeze

SELECT squeeze.squeeze_table('public', 'pgbench_accounts');

SELECT squeeze.squeeze_table(
  'public',
  'large_table',
  'large_table_cluster_idx',
  'target_tablespace'
);

The function starts background work and is not transactional in the ordinary SQL-function sense. Monitor the operation rather than assuming a surrounding ROLLBACK cancels it.

Schedule Tables and Monitor Work

INSERT INTO squeeze.tables (tabschema, tabname, schedule)
VALUES ('public', 'events', ('{30}', '{22}', NULL, NULL, '{3,5}'));

SELECT * FROM squeeze.get_active_workers();
SELECT * FROM squeeze.log ORDER BY finished DESC;
SELECT * FROM squeeze.errors;

The schedule tuple contains minutes, hours, days of month, months, and days of week. Registration also supports thresholds and placement options such as free_space_extra, min_size, vacuum_max_age, max_retry, clustering_index, relation/index tablespaces, and skip_analyze.

For automatic startup:

squeeze.worker_autostart = 'my_database'
squeeze.worker_role = 'postgres'

Version 1.9.4 and Operational Caveats

  • Version 1.9.4 fixes unsafe quoting in dynamically constructed ANALYZE, log, and error statements, including a superuser SQL-injection path. Upgrade earlier 1.9 builds promptly.
  • A full-table squeeze needs free disk space of roughly twice the combined size of the target table and its indexes.
  • Disruptive DDL, VACUUM FULL, CLUSTER, or TRUNCATE can make an in-progress squeeze abort. Coordinate schema changes and use max_retry deliberately.
  • Like other online rewrite tools, pg_squeeze changes row visibility and has documented MVCC caveats for concurrent sessions that retain old snapshots.
  • Configure pg_squeeze in shared_preload_libraries on the new cluster before pg_upgrade or dump/restore of a database containing the extension.
  • Current Pigsty packages cover PostgreSQL 14-18. For those versions, keep wal_level = logical; upstream’s relaxed PostgreSQL 19 rule does not apply to this package matrix yet.
Last updated on