Why PostgreSQL major version upgrades are hard

submited by
Style Pass
2024-11-26 08:30:02

Upgrades between PostgreSQL major versions are famously annoying. You can’t just install the server binaries and restart, because the format of the data directory is incompatible.

Perhaps surprisingly, the data format is actually mostly compatible, but not completely. There are just a few things missing that are very hard to solve.

2 and 3 are essentially the same idea: Build a new instance and transport the data between the instances in a higher-level, compatible format.

Take a dump (using pg_dump) of the schema of the old database, and restore that to the new database. (Actually separately for each database in the instance, and in combination with pg_dumpall, but that’s not important here.)

So the data files, which contain the table and index data, are actually compatible between major versions. They have been for a long time, ever since pg_upgrade was introduced.

heap is more complicated, it just has to maintain compatibility with whatever old versions might have stored. But in any case, this works.

Leave a Comment