A CLI tool for performing zero-downtime schema changes and backfills in PostgreSQL using a shadow table approach.
pg-osc (pg-online-schema-change) is a command-line utility that enables safe, online schema modifications on PostgreSQL tables. It allows database administrators to execute ALTER statements without significant downtime or locking issues, making it suitable for production environments with high write volumes.
Database administrators and DevOps engineers managing PostgreSQL databases in production environments, especially those needing to perform schema changes on high-traffic tables with minimal disruption.
Developers choose pg-osc over native PostgreSQL ALTER statements because it minimizes locking to brief ACCESS EXCLUSIVE locks only during trigger setup and table swap, uses a shadow table migration approach to ensure data integrity, and offers performance tuning options for high-volume workloads.
Easy CLI tool for making zero downtime schema changes and backfills in PostgreSQL
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses ACCESS EXCLUSIVE locks only during trigger setup and table swap phases, drastically reducing downtime compared to native ALTER statements, as highlighted in the README's caveats.
Preserves indexes, foreign keys, and constraints via shadow table migration with trigger-based synchronization, ensuring no data loss during schema transitions.
Offers configurable batch sizes and delta thresholds for replaying workloads, making it adaptable for high-traffic tables, as shown in the examples for replaying larger workloads.
Allows custom SQL during data copy for backfilling or transforming columns, enabling complex data migrations, though the README warns of risks like data loss if not used carefully.
The README admits partitioned tables are not supported, limiting its use in modern PostgreSQL environments that rely on partitioning for large datasets.
Requires a primary key on the table; without it, pg-osc raises an exception, making it unusable for tables lacking a PK or with composite keys not set as primary.
Index and constraint names are changed during the process, losing original naming which can break application dependencies or monitoring tools.
Needs sufficient disk space to duplicate the table, which can be a constraint for very large tables or environments with limited storage.