Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. PostgreSQL
  3. pg_squeeze

pg_squeeze

NOASSERTIONCREL1_9_4

A PostgreSQL extension that automatically removes table bloat and optionally sorts tuples by an index, using background workers and logical decoding.

GitHubGitHub
703 stars40 forks0 contributors

What is pg_squeeze?

pg_squeeze is a PostgreSQL extension that automatically reclaims unused space (bloat) from tables and can physically reorder tuples according to a specified index. It performs these operations concurrently with regular reads and writes, similar to the CLUSTER command but without blocking access. The project aims to replace pg_repack by implementing functionality purely on the server side using modern PostgreSQL features.

Target Audience

Database administrators and DevOps engineers managing PostgreSQL databases who need to maintain performance by reducing table bloat without downtime. It's particularly valuable for teams running large, write-heavy databases where table fragmentation impacts query performance.

Value Proposition

Developers choose pg_squeeze over alternatives like pg_repack because it's a pure server-side implementation that leverages PostgreSQL's background workers and logical decoding for simpler configuration and unattended operation. It provides finer control over scheduling, tablespace management, and concurrency impact with minimal overhead compared to trigger-based solutions.

Overview

A PostgreSQL extension for automatic bloat cleanup

Use Cases

Best For

  • Automated bloat cleanup in PostgreSQL databases without manual intervention
  • Reorganizing tables according to specific indexes while maintaining read/write access
  • Moving tables and indexes between tablespaces without downtime
  • Managing large, frequently updated tables where VACUUM FULL would cause unacceptable blocking
  • Scheduled maintenance operations in multi-tenant database environments
  • Replacing pg_repack with a simpler, server-only architecture

Not Ideal For

  • Environments where PostgreSQL configuration cannot be altered (e.g., restrictive managed cloud services), as it requires wal_level=logical and shared_preload_libraries
  • Tables lacking primary keys or replica identity indexes, since an identity index is mandatory for processing
  • Systems with critically limited disk space, given the need for approximately double the table size during operation
  • Databases with frequent schema changes, because ALTER TABLE commands during processing can cause failures and retries

Pros & Cons

Pros

Pure Server-Side Implementation

Runs entirely within PostgreSQL, eliminating client-side dependencies and simplifying deployment compared to tools like pg_repack.

Concurrent Access

Uses logical decoding to capture changes without triggers, allowing reads and writes during processing with minimal blocking.

Automated Scheduling

Supports cron-like schedules via the squeeze.tables table, enabling background workers to automatically check and process bloated tables.

Tablespace Management

Can move tables and indexes to different tablespaces during reorganization, aiding in storage optimization without downtime.

Cons

Invasive Setup

Requires PostgreSQL server configuration changes (wal_level, replication slots, shared_preload_libraries) and a restart, which can be disruptive in production.

High Disk Space Demand

Needs free disk space about twice the size of the target table and indexes during operation, posing challenges for large or space-constrained databases.

Index Dependency

Tables must have an identity index; if absent, manual setup with ALTER TABLE is required, adding complexity for schemas without proper indexes.

Sensitive to Changes

Processing can abort if table definitions are altered concurrently, necessitating retries and careful scheduling to avoid disruptions.

Open Source Alternative To

pg_squeeze is an open-source alternative to the following products:

pg_repack
pg_repack

pg_repack is a PostgreSQL extension that reorganizes tables online to reclaim storage space and improve performance without requiring exclusive locks.

Frequently Asked Questions

Quick Stats

Stars703
Forks40
Contributors0
Open Issues1
Last commit1 month ago
CreatedSince 2016

Tags

#concurrent-operations#postgresql#postgresql-extension#database-optimization#extension#self-hosted#logical-decoding

Built With

P
PostgreSQL
C
C++

Included in

PostgreSQL11.8k
Auto-fetched 1 day ago

Related Projects

CitusCitus

Distributed PostgreSQL as an extension

Stars12,822
Forks802
Last commit2 days ago
AGEAGE

Graph database optimized for fast analysis and real-time data processing. It is provided as an extension to PostgreSQL.

Stars4,910
Forks539
Last commit9 days ago
ZomboDBZomboDB

Making Postgres and Elasticsearch work together like it's 2023

Stars4,719
Forks212
Last commit1 year ago
pg_cronpg_cron

Run periodic jobs in PostgreSQL

Stars3,907
Forks265
Last commit1 month ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub