title

text

Андрей Черняков
Андрей Черняков UIS, CoMagic
17:40 01 April
40 min

pg-transparent-alter-table: Modifying Large Tables Under Load Without Locks with One Command

Making changes to tables under production load is always a complex task. For example, when you need to change a column type (e.g., from int to bigint or from timestamp to timestamptz), or move a table to a different tablespace without losing any changes that occur during the data migration.

What if you have hundreds of such tables? With pg-transparent-alter-table, this is no longer a problem. These tasks can be solved with a single simple command:
$ pg_tat -h 0.0.0.0 -d mydb -c "alter table mytable alter column id bigint"

Key features include:

  • You can specify any number of alter table commands at once.
  • You can modify partitioned tables, supporting both the old inheritance-based partitioning and new declarative partitioning, including multi-level partitioning.
  • You can interrupt the process at any stage and continue later without losing progress from previous stages.
  • You can change your mind at any time, stop the execution, run "pg_tat --clean," and revert to the original state.
  • Custom commands for changing column order.
  • PostgreSQL version support: 11-17.

After more than 5 years of existence (previously called transparent-alter-type), the project has become a reliable tool actively used in production. I would like to share my experience and discuss its capabilities.

Other talks