PostgreSQL 19 Released: REPACK CONCURRENTLY, ON CONFLICT DO SELECT and an Upgrade Checklist
What Shipped on November 19?
The PostgreSQL Global Development Group released PostgreSQL 19 on Thursday, November 19, 2026. The release notes carry the same date.
Most coverage leads with one feature: REPACK (CONCURRENTLY), which removes table bloat without blocking reads or writes. Some smaller changes will matter more to an application developer day to day. You get a real get-or-create in one statement, COPY straight to JSON, and logical replication you can switch on without a restart.
This guide covers the features I'd actually use and the incompatibilities that can trip up an upgrade. It ends with a checklist.
As with every major version, moving from an earlier release needs a dump and restore (pg_dumpall), pg_upgrade, or logical replication. The release notes say so in their migration section.
REPACK Replaces VACUUM FULL and CLUSTER
REPACK reclaims space from a bloated table and can reorder its rows to match an index. The announcement calls it the replacement for VACUUM FULL and CLUSTER. Both old commands still work for compatibility.
The REPACK reference page gives this synopsis:
REPACK [ ( option [, ...] ) ] [ table_and_columns [ USING INDEX [ index_name ] ] ]
REPACK [ ( option [, ...] ) ] USING INDEX
-- option: VERBOSE | ANALYZE | CONCURRENTLY [ boolean ]
And these two examples:
REPACK employees;
REPACK (CONCURRENTLY) employees USING INDEX;
What CONCURRENTLY actually costs you
Without CONCURRENTLY, REPACK holds an ACCESS EXCLUSIVE lock for the whole run, the same pain as VACUUM FULL. With it, most of the work runs under SHARE UPDATE EXCLUSIVE. ACCESS EXCLUSIVE is taken only for the final swap, so it is usually held briefly.
Read the restrictions before you schedule it on a production table. The reference page lists them:
- Primary key or replica identity required. It won't run on a table with no primary key and no index-based replica identity.
- Not every table qualifies. It won't run on partitioned tables,
UNLOGGEDtables, materialized views, system catalogs, TOAST tables, or tables whose access method isn'theap. - No transaction blocks. You can't run it inside a transaction block, and the form without a table name can't use
CONCURRENTLY. - It needs a replication slot. It uses logical decoding, so it fails if
max_repack_replication_slotsdoesn't allow another slot. - It needs disk. Captured changes are stored on disk while it runs.
- It can fail on write-heavy tables. It fails if more than about 104 million rows are updated or deleted during the run, and DDL from other sessions can also make it fail.
- It is not MVCC-safe. After it commits, a transaction using a snapshot taken before the repack started may see the table as empty.
The last point matters if you run long reporting transactions or pg_dump alongside it. Schedule around them.
Developer Features Worth Using
Get-or-create with ON CONFLICT DO SELECT
Until now, "insert this row or give me the existing one" took either a CTE or a no-op DO UPDATE just to make RETURNING fire. PostgreSQL 19 adds a third conflict action, DO SELECT. This example comes straight from the INSERT reference:
INSERT INTO distributors (did, dname) VALUES (11, 'Global Electronics')
ON CONFLICT (did) DO SELECT
RETURNING *;
You can also lock the existing row while you're at it:
INSERT INTO distributors (did, dname) VALUES (13, 'Advanced Systems')
ON CONFLICT (did) DO SELECT FOR UPDATE
RETURNING *;
The synopsis allows FOR UPDATE, FOR NO KEY UPDATE, FOR SHARE or FOR KEY SHARE, plus an optional WHERE condition. If your ORM writes upserts for you, check whether it uses the new form before you change hand-written SQL.
COPY straight to JSON
COPY TO now accepts FORMAT json. Add FORCE_ARRAY and the whole output is one JSON array. Here is the example from the COPY reference:
COPY (SELECT * FROM (VALUES(1),(2)) val(id)) TO STDOUT (FORMAT JSON, FORCE_ARRAY);
[
{"id":1}
,{"id":2}
]
Two gotchas from the docs. JSON format is allowed only in COPY TO, not COPY FROM. And a SQL NULL and a JSON-literal null both come out as null, so you can't tell them apart in the output. To inspect an export, paste it into the JSON viewer or JSON prettifier. If someone needs it in a spreadsheet, the JSON to CSV converter will flatten it.
Smaller SQL additions
The announcement and release notes also list:
- More SQL/JSON path string methods:
lower(),upper(),replace(),split_part()andbtrim(). IGNORE NULLSin window functions:lead(),lag(),first_value(),last_value()andnth_value()now acceptIGNORE NULLS(orRESPECT NULLS).- Random dates:
random()can generate dates and timestamps within a range. - Password expiry warnings:
password_expiration_warning_thresholdwarns users before their password expires. The default is seven days.
Replication and Operations Changes
- Logical replication without a restart. The effective WAL level is raised to
logicalwhen the first logical replication slot is created. Check it with the neweffective_wal_levelsetting. - Sequences replicate.
CREATE PUBLICATIONacceptsFOR ALL SEQUENCES. It also gains anEXCEPTclause for leaving tables out ofFOR ALL TABLES. - Read-your-writes on replicas. The announcement describes a
WAIT FOR LSNcommand that makes a standby session wait until it has replayed WAL up to a given LSN. That's useful when a write goes to the primary and the next read goes to a replica. - Plan pinning. The
pg_plan_adviceextension pins plan choices with a "plan advice" mini-language.pg_stash_advicestores that advice and applies it by query identifier, so you can fix a slow plan without changing the application. - Autovacuum. Autovacuum can vacuum indexes with parallel workers (
autovacuum_max_parallel_workers). A newpg_stat_autovacuum_scoresview shows how it ranks tables. - SNI. One server can present a different TLS certificate per hostname, configured in the new
pg_hosts.conf. - Faster bulk loads. Foreign key checks are faster. The project reports bulk inserts nearly 2x faster in its testing.
Incompatibilities That Can Break an Upgrade
These come from section E.1.2 of the release notes. I've grouped them by how likely they are to bite a typical app.
Check these first
standard_conforming_stringsis always on. Dumps made by a pre-19pg_dumpwhile it wasoffmay not load, andescape_string_warningis gone. If you restore old dumps, test one now.- MD5 passwords now warn. A successful MD5 login logs a warning, which you can silence with
md5_password_warnings. MD5 was deprecated in 18 and will be removed in a future release, so plan the move to SCRAM using the password authentication docs. - RADIUS authentication is removed.
- JIT is off by default. If you run many large analytical queries, turn it back on and compare.
max_locks_per_transactionchanged. The default went from 64 to 128, and lock allocation changed with it. If you set it yourself, the notes say you effectively need to double your old value to keep the same capacity.io_workersis removed. It's replaced byio_min_workers,io_max_workers,io_worker_idle_timeoutandio_worker_launch_interval. A config file that still setsio_workersneeds editing.
Reindex after upgrading
- Full text search and
pg_trgmnow classify characters using the database's locale provider instead of always using libc. Reindex affected indexes and recompute storedtsvectorvalues. fuzzystrmatchchanged howdmetaphone(),soundex(),metaphone()anddifference()treat letters. Reindex anything built on them.- btree_gist
inet/cidrindexes can exclude rows that should be returned, andpg_upgraderefuses clusters that have them.
Behaviour and monitoring changes
json_array()with no rows now returns an empty array instead ofNULL.COPY FROM ... WHEREno longer accepts system columns.postgres_fdwnow passesREAD ONLYto the remote session, so read-only transactions can no longer modify rows through it.- Database, role and tablespace names can no longer contain carriage returns or line feeds.
pg_upgraderejects clusters that use them. - Dashboards may need updates.
pg_stat_subscription_stats.sync_error_countis nowsync_table_error_count. Wait event typeBUFFERPINis nowBUFFER, andBufferContentis split into three events. MULE_INTERNALencoding is removed. A database using it has to be dumped and restored with another encoding.
Upgrade Checklist
- Read the migration notes. Section E.1.2 of the release notes is the source; this article is a summary.
- Search your config. Look for
io_workers,max_locks_per_transactionand anything that relies on JIT. - Audit authentication. Find MD5 and RADIUS in
pg_hba.conf, and move MD5 users to SCRAM. - Test-restore an old dump. Use one made by your current
pg_dumpand load it into a 19 instance. - Do a
pg_upgrade --checkrun. Try it on a copy. It flags btree_gistinet/cidrindexes and names with line breaks. - Plan reindexes. Budget time for full text search,
pg_trgmandfuzzystrmatchindexes after the upgrade. - Update monitoring. Fix queries that use the renamed columns and wait events.
- Adopt new features later. Once you're stable on 19, try
ON CONFLICT DO SELECT,COPY ... FORMAT jsonandREPACK (CONCURRENTLY).
Downloads are on the PostgreSQL download page. For how long 19 will be supported, see the project's versioning policy.
