Inkpost, home
Cover reading "PostgreSQL 19, tested and explained" with feature chips, beside a psql terminal showing REPACK shrinking a table from 357 MB to 239 MB, WAIT FOR LSN succeeding, and ON CONFLICT DO SELECT.

Databases · SQL & PostgreSQL

PostgreSQL 19, tested and explained: every new feature and what changes when you upgrade

REPACK without downtime, plan advice, WAIT FOR LSN, sequence replication, ON CONFLICT DO SELECT, COPY to JSON and the new defaults, each run on a real PostgreSQL 19.0 server, plus an upgrade checklist.

Suman AcharyyaVerified@sumanacharyya999

15 min read

PostgreSQL 19 was released on 19 November 2026, about two months later than usual, after several beta features were pulled rather than shipped half-ready. What did ship is about the work you do every week: removing table bloat without downtime, holding a query to a good plan when the planner changes its mind, reading your own writes from a replica, setting up logical replication without a restart, and a handful of SQL features that delete code from your application. This guide covers all of it, plus the defaults that change under you when you upgrade.Source [1]

Transcript
PostgreSQL 19, tested and explained: every new feature, and what changes when you upgrade. REPACK replaces VACUUM FULL and CLUSTER. With CONCURRENTLY, reads and writes continue until a brief final swap. Autovacuum can vacuum indexes in parallel and uses scores to decide which tables to process first. Plan advice shows the planner's choices, lets you pin just the one that matters, and applies it by query ID. Logical replication no longer needs a restart, and sequences replicate too. Refresh them right before cutover. WAIT FOR LSN lets a standby wait until it has replayed your write, so users always read their own changes. ON CONFLICT DO SELECT gives get-or-create in one statement. COPY writes JSON, and window functions can ignore nulls. Check the new defaults: JIT is off, TOAST uses LZ4, lock limits doubled, MD5 warns and RADIUS is gone. Run pg_upgrade --check, rehearse, and plan now: PostgreSQL 14 reached end of life on 12 November 2026.

Where 19 fits: supported versions

Each major version is supported for five years, so 15 to 19 are now supported. Version 14 reached end of life on 12 November 2026, a week before 19 shipped.Source [2]

Version

Released

Supported until

19

19 Nov 2026

19 Nov 2031

18

25 Sep 2025

14 Nov 2030

17

26 Sep 2024

8 Nov 2029

16

14 Sep 2023

9 Nov 2028

15

13 Oct 2022

11 Nov 2027

14

30 Sep 2021

Ended 12 Nov 2026

What you already had in 18

Jumping from 16 or 17? These arrived in 18, and 19 builds on them:Source [3]

Feature (since 18)

What it gives you

Asynchronous I/O (io_method)

Reads issued ahead instead of one by one; 19 scales its workers

uuidv7()

Time-ordered UUIDs that index well

Virtual generated columns

Computed on read; the default kind since 18

RETURNING OLD / NEW

Before and after values in one UPDATE, DELETE or MERGE

pg_upgrade keeps statistics

No long ANALYZE after upgrading

What didn't make it

Several features that appeared in 19's betas were reverted before release: SQL property graph queries (GRAPH_TABLE), partition merge and split, turning data checksums on and off while the server runs, GROUP BY ALL, and UPDATE/DELETE ... FOR PORTION OF. If you read about any of these in a beta-era post, they are not in 19.0. On the final build, GROUP BY ALL and GRAPH_TABLE are plain syntax errors. The earliest they can return is PostgreSQL 20.Source [4]

1. REPACK: remove bloat without taking the table offline

PostgreSQL never overwrites a row in place: an UPDATE writes a new version and a DELETE only marks the old one dead. VACUUM makes that space reusable but doesn't return it to the operating system. After deleting 80% of a million test orders and vacuuming, our table was still 63 MB with 31 MB of indexes.

Shrinking it used to mean VACUUM FULL or CLUSTER, which lock the table for the whole rewrite, or the third-party pg_repack extension. PostgreSQL 19 replaces both commands with REPACK; the old ones remain for compatibility.Source [5]

-- How bloated is it? (dummy store: 1M orders, then 80% deleted)SELECT pg_size_pretty(pg_table_size('orders'))   AS table_size,       pg_size_pretty(pg_indexes_size('orders')) AS index_size;--  table_size | index_size--  63 MB      | 31 MB-- Rebuild table + indexes while reads and writes continueREPACK (CONCURRENTLY, VERBOSE) orders;--  table_size | index_size--  13 MB      | 5976 kB-- What CLUSTER used to do: physically order rows by an index, then refresh statsREPACK (ANALYZE) orders USING INDEX orders_customer_idx;
Timeline of REPACK (CONCURRENTLY): copy and index rebuild under a weak lock, then applying captured changes, then a brief exclusive swap. Reads and writes continue until the swap. Our test: 357 MB to 239 MB with 48 inserts during the run.
Old VACUUM FULL blocks the table for the whole rewrite; REPACK (CONCURRENTLY) only blocks for the final file swap.

Plain REPACK holds an ACCESS EXCLUSIVE lock for the whole run. With CONCURRENTLY, the copy runs under a weaker SHARE UPDATE EXCLUSIVE lock while logical decoding records other sessions' changes; those are replayed, and only the final swap takes the exclusive lock. On a 4-million-row table (357 MB) under steady inserts, it finished in 4.0 seconds, 48 inserts committed during it, none failed, and the table came out at 239 MB.Source [6]

What concurrent repacking needs

  • Free disk space at least equal to the table plus all its indexes, because both copies exist until the swap.

  • A primary key or an index-based replica identity. It can't run on unlogged, partitioned or non-heap tables, materialized views or system catalogs, or inside a transaction block.

  • A free replication slot (max_repack_replication_slots, default 5). While it runs, the effective WAL level is raised to logical automatically and drops back afterwards; we watched it happen.

  • No DDL on the table while it runs, under about 104 million concurrently changed rows, and no long transactions near the final swap.

2. Autovacuum that keeps up, and tells you why

Autovacuum can now vacuum a table's indexes with parallel workers: opt in server-wide with autovacuum_max_parallel_workers (0 by default) and per table with the autovacuum_parallel_workers storage parameter. It picks what to process first with a scoring system, tunable through five autovacuum_*_score_weight settings. And ordinary queries can mark pages all-visible as they read them, saving later vacuum work and helping index-only scans.Source [7]

You can see the scores directly in a new view. After some deletes and updates on our test tables, autovacuum's queue looked like this:

SELECT relname, round(score::numeric, 2) AS score, do_vacuum, do_analyze
FROM pg_stat_autovacuum_scores ORDER BY score DESC LIMIT 4;

   relname    | score | do_vacuum | do_analyze
--------------+-------+-----------+------------
 accounts     |  9.52 | t         | t
 sales        |  2.50 | t         | t
 pg_attribute |  0.96 | f         | f
 pg_depend    |  0.85 | f         | f

New in 19

Shows

pg_stat_autovacuum_scores

Each table's priority score, its parts, and whether it's due

pg_stat_lock

Waits and wait time per lock type

pg_stat_recovery

A standby's replay position and pause state

pg_stat_progress_repack

Progress of a running REPACK

EXPLAIN (ANALYZE, IO)

Asynchronous I/O activity per plan node

wal_fpi_bytes in pg_stat_wal and EXPLAIN (ANALYZE, WAL)

WAL spent on full-page images

3. Plan advice: hold a query to a plan you trust

The planner is usually right, but skewed data can fool it. In our test store, 1% of accounts are enterprise customers placing 30% of orders. Underestimate that and the planner may do an index lookup per account instead of one hash join. Forcing each plan shows the difference:

Plan (same query, 2 million sales)

Execution time

Buffers touched

Nested loop + index scan per account

324 ms

394,791

Hash join

64 ms

12,904

Version 19 adds a supported alternative to hints in two contrib modules. pg_plan_advice describes the planner's key decisions in a small advice language, lets you supply advice, and reports whether it was followed. pg_stash_advice applies stored advice by query ID, so you can fix a regressed query without touching application code.Source [8]

shared_preload_libraries = 'pg_plan_advice, pg_stash_advice'
-- 1. See the planner's decisions as adviceEXPLAIN (COSTS OFF, PLAN_ADVICE)SELECT a.plan, sum(s.amount)FROM accounts a JOIN sales s ON s.account_id = a.idWHERE a.plan = 'enterprise' GROUP BY a.plan;--  Generated Plan Advice: JOIN_ORDER(s a) HASH_JOIN(a) SEQ_SCAN(s a) GATHER((a s))-- 2. Try advice in this session; feedback shows it was usedSET pg_plan_advice.advice = 'JOIN_ORDER(s a) HASH_JOIN(a)';--  Supplied Plan Advice: JOIN_ORDER(s a) /* matched */  HASH_JOIN(a) /* matched */-- 3. Apply it automatically by query ID (from EXPLAIN (VERBOSE) or pg_stat_statements)CREATE EXTENSION pg_stash_advice;SELECT pg_create_advice_stash('prod');SELECT pg_set_stashed_advice('prod', -2422606971101914697, 'JOIN_ORDER(s a) HASH_JOIN(a)');ALTER DATABASE shop SET pg_stash_advice.stash_name = 'prod';

Advice constrains the planner rather than replacing it: it rules out alternatives, so you only get plans the planner would have considered, and impossible advice yields nodes marked Disabled: true, never an error. Feedback (matched, partially matched, not matched, failed) shows what happened. Tags cover join order (JOIN_ORDER), join methods (HASH_JOIN, NESTED_LOOP_PLAIN, MERGE_JOIN_PLAIN...), scans (SEQ_SCAN, INDEX_SCAN, BITMAP_HEAP_SCAN...) and parallelism (GATHER, NO_GATHER).Source [9]

Overriding its judgment can easily backfire.

PostgreSQL 19 documentation, pg_plan_advice

4. Logical replication without restarts, now with sequences

Logical replication used to need wal_level = logical, which meant a restart planned weeks ahead. In 19, with the default replica, the server raises its effective level to logical automatically when the first logical slot is created; the read-only effective_wal_level shows what's in use.Source [10]

The other gap was sequences: rows were copied but sequence values weren't, so the first inserts after a migration failed with duplicate keys. Publications can now include ALL SEQUENCES, and FOR ALL TABLES accepts an EXCEPT list.

-- PUBLISHER (19), wal_level still 'replica', no restartCREATE PUBLICATION shop_pub  FOR ALL TABLES EXCEPT (TABLE audit_log),      ALL SEQUENCES;-- SUBSCRIBER (schema created first with pg_dump --schema-only)CREATE SUBSCRIPTION shop_sub  CONNECTION 'host=pg19-primary.internal dbname=shop user=replicator'  PUBLICATION shop_pub;-- PUBLISHER: SHOW effective_wal_level;  -> logical (raised by the new slot)-- Rows stream, sequences don't (publisher 12, subscriber 9). At cutover:ALTER SUBSCRIPTION shop_sub REFRESH SEQUENCES;   -- subscriber now 12

Also new: CREATE SUBSCRIPTION ... SERVER takes connection settings from a foreign server (for example one defined for postgres_fdw) instead of a connection string; retain_dead_tuples detects updates that conflict with a concurrent delete when several systems write the same data; and postgres_fdw's import_stats option imports remote statistics during ANALYZE instead of sampling rows over the network.

5. WAIT FOR LSN: read your own writes from a replica

Sending reads to replicas is the easiest way to scale PostgreSQL, until a customer places an order and the next page, served by a slightly-behind replica, says they have none. The usual workarounds are sleeps, polling or reading from the primary.

Flow diagram: the app commits an order on the primary at LSN 1/178379B8, carries that LSN to the next request, and the standby runs WAIT FOR LSN until it has replayed that far, then the read finds the new order.
Carry the commit LSN with the user's session, and let the standby wait for it instead of sleeping or polling.

Every change has a position in the write-ahead log, its LSN. After a write commits, the application takes the primary's current LSN and carries it with the user's session. Before reading on the replica, it runs WAIT FOR LSN, which blocks until the replica has replayed that far:

-- PRIMARY, right after the write commitsINSERT INTO customers (email, name) VALUES ('meera@example.com', 'Meera Sen');SELECT pg_current_wal_insert_lsn();   -- 1/178379B8, keep it in the session-- STANDBY, before readingWAIT FOR LSN '1/178379B8' WITH (TIMEOUT '2s');            -- successSELECT id, email FROM customers WHERE email = 'meera@example.com';-- Status instead of an error: success | timeout | not in recoveryWAIT FOR LSN '1/178379B8' WITH (TIMEOUT '200ms', NO_THROW);

Mode

Waits until

Runs on

standby_replay (default)

The LSN has been replayed, so the data is visible to queries

Standby

standby_flush

The WAL is flushed to the standby's disk (durable, maybe not yet visible)

Standby

standby_write

The WAL is written, but maybe not flushed (fastest, weakest)Source [12]

Standby

primary_flush

The WAL is flushed on the primary

Primary

Without NO_THROW, a timeout is an error that aborts the transaction; with it, the application gets a status and decides whether to retry or read from the primary. The default mode errors on a primary, as we confirmed.

6. SQL that removes application code

ON CONFLICT DO SELECT: get or create in one statement

"Find the customer by email, or create them" used to be awkward. DO NOTHING returns no row when the customer exists, so you need a second query, and the usual no-op DO UPDATE trick writes a new row version every time. DO SELECT returns the existing row without writing anything:

CREATE TABLE customers (  id    int GENERATED ALWAYS AS IDENTITY PRIMARY KEY,  email text NOT NULL UNIQUE,  name  text NOT NULL,  tier  text NOT NULL DEFAULT 'free');-- Get or create, one statement, no write when the row existsINSERT INTO customers (email, name)VALUES ('asha@example.com', 'Asha R.'),     -- exists: returned as is       ('dev@example.com',  'Dev Kumar')    -- new: insertedON CONFLICT (email) DO SELECTRETURNING id, email, name;--  id |      email       |   name--   1 | asha@example.com | Asha Rao--   5 | dev@example.com  | Dev Kumar-- Add FOR UPDATE to lock the existing row for the rest of the transaction--   ... ON CONFLICT (email) DO SELECT FOR UPDATE RETURNING id;

I checked: after DO SELECT the row's xmin and ctid were unchanged, while the no-op DO UPDATE wrote a new version. DO SELECT needs a conflict target such as (email), and identity values are still used up on conflicts, which is why Dev's id is 5, not 2.Source [13]

JSON, window functions and test data

-- COPY to JSON: one object per line, or one array with FORCE_ARRAYCOPY (SELECT id, email, tier FROM customers ORDER BY id) TO STDOUT (FORMAT json);-- {"id":1,"email":"asha@example.com","tier":"free"}-- {"id":5,"email":"dev@example.com","tier":"pro"}-- IGNORE NULLS: carry the last known price forwardSELECT at, price, last_value(price) IGNORE NULLS OVER (ORDER BY at) AS last_knownFROM price_ticks ORDER BY at;--  2026-11-21 | NULL | 101.5   (gap filled)-- JSON path string methodsSELECT jsonb_path_query('{"sku":"  kb-Mech-87 "}', '$.sku.btrim().upper()');   -- "KB-MECH-87"-- random() for dates and timestampsSELECT random('2026-01-01'::date, '2026-12-31'::date);
  • COPY ... (FORMAT json) is output only: COPY FROM doesn't accept JSON, and HEADER, DELIMITER and NULL options are rejected. A SQL NULL and a JSON null value look the same in the output.

  • Behaviour change: json_array() over zero rows now returns [] instead of NULL. Check code that tests for NULL.

7. Faster without changing anything

  • Foreign-key checks are cheaper. The release announcement reports bulk inserts into tables with foreign keys running nearly twice as fast in testing.

  • NOT IN (subquery) becomes an anti-join when no NULLs are possible; on our tables the plan now reads Nested Loop Anti Join with an index-only scan.

  • Eager aggregation: the planner can aggregate before a join so it joins far fewer rows. On by default (enable_eager_aggregate), used when grouping shrinks rows at least eightfold (min_eager_agg_group_size).Source [14]

  • Asynchronous I/O workers scale themselves. With io_method = worker, the default, the number of I/O workers moves between io_min_workers (2) and io_max_workers (8). These replace the old fixed io_workers setting.Source [15]

8. Defaults and security changes to check

These are the changes most likely to surprise you after an upgrade. Every value below is what a fresh 19.0 server reported:Source [16]

Setting

18

19

What to do

jit

on

off

Re-enable only for heavy analytical roles

default_toast_compression

pglz

lz4

Faster; existing data isn't recompressed

max_locks_per_transaction

64

128

Allocation changed: double any custom value

log_lock_waits

off

on

More log lines on contended systems

io_workers

fixed

removed

Use io_min_workers / io_max_workers (2 / 8)

password_expiration_warning_threshold

-

7 days

Warns before a VALID UNTIL password expires

md5_password_warnings

-

on

MD5 logins log a warning; move to SCRAM

standard_conforming_strings

settable

always on

Old dumps made with it off won't load

  • RADIUS authentication is gone. It only supported UDP, which the project considers unfixably insecure. Move those users to another method before upgrading.

  • TLS Server Name Indication: one server can present different certificates for different host names, mapped in the new pg_hosts.conf file. Useful when one server answers to several domains.

  • READ ONLY transactions now carry over to postgres_fdw, and parallel VACUUM workers share one vacuum_cost_limit with their leader, so throttled parallel vacuum may be slower.Source [17]

9. Upgrading to 19

Going from any earlier major version needs pg_upgrade, a dump and restore, or logical replication, which 19 now makes easier with sequence sync. pg_upgrade refuses to proceed in a few cases, so run its check first:Source [18]

# 1. Dry run: reports incompatibilities (btree_gist inet/cidr indexes,#    names with line breaks, MULE_INTERNAL encoding...) without touching datapg_upgrade --check \  --old-bindir /usr/lib/postgresql/18/bin --new-bindir /usr/lib/postgresql/19/bin \  --old-datadir /var/lib/postgresql/18/main --new-datadir /var/lib/postgresql/19/main# 2. The real upgrade. --swap moves the data directory instead of copying it;#    planner statistics are carried over, so no long ANALYZE before trafficpg_upgrade --swap --jobs 8 \  --old-bindir /usr/lib/postgresql/18/bin --new-bindir /usr/lib/postgresql/19/bin \  --old-datadir /var/lib/postgresql/18/main --new-datadir /var/lib/postgresql/19/main# 3. After starting 19: rebuild text-search, pg_trgm and fuzzystrmatch indexespsql -d shop -c "REINDEX INDEX CONCURRENTLY products_name_trgm_idx;"
  1. Rehearse on a copy of production with your real extensions, drivers and queries, and confirm every extension has a 19 build.

  2. Run pg_upgrade --check. Replace btree_gist indexes on inet/cidr columns, rename anything with a line break in its name (databases, roles, tablespaces) and move off the removed MULE_INTERNAL encoding.

  3. After the upgrade, reindex full-text search, pg_trgm and fuzzystrmatch indexes and recompute stored tsvector values; they now follow the database's locale provider.

  4. Then adopt the new tools one at a time: repack your most bloated table, add advice for the one query that keeps regressing, and use WAIT FOR LSN where you read from replicas.

PostgreSQL 19 in under two minutes1:39
Transcript
PostgreSQL 19, the short version. PostgreSQL 19 was released on the nineteenth of November 2026. It focuses on everyday work, and several big beta features were held back rather than rushed. First, maintenance. The new REPACK command replaces VACUUM FULL and CLUSTER, and REPACK CONCURRENTLY rebuilds a bloated table while reads and writes continue, taking an exclusive lock only for a short final swap. It needs extra disk space and a primary key, and it isn't safe for very old open transactions. Autovacuum can now clean indexes in parallel, and it uses a score to decide which tables need attention first. Second, plan stability. The pg plan advice module shows the planner's decisions as short advice, and lets you pin just the decision that matters, such as a hash join. Its companion, pg stash advice, applies that advice automatically by query ID, so you can fix a bad plan without changing application code. Third, replication. Logical replication no longer needs a server restart, and sequence values can now be replicated. Refresh them just before you cut over. On read replicas, WAIT FOR LSN lets a standby wait until it has replayed a write, so users always see their own changes. For developers, ON CONFLICT DO SELECT gives you get or create in one statement, COPY can write JSON, and window functions can ignore nulls. Before upgrading, check the new defaults. JIT is off, TOAST compression uses LZ4, the lock limit doubled, MD5 logins warn, and RADIUS is gone. Run pg upgrade with the check option first, and rehearse on a copy of production.

Go further

The official release notes list every change in PostgreSQL 19, including many smaller items not covered here:


PostgreSQL 19 turns jobs that used to need extensions, restarts or application code into plain SQL. That's the kind of release that pays off every week.

Sources

  1. Release 19, PostgreSQL Global Development Group. Accessed 2026-11-27. Back to the text for source 1
  2. Versioning Policy, PostgreSQL Global Development Group. Accessed 2026-11-27. Back to the text for source 2
  3. PostgreSQL 18 Released!, PostgreSQL Global Development Group. Accessed 2026-11-27. Back to the text for source 3
  4. PostgreSQL 19: What changed, what matters, and what to test now, EDB. Accessed 2026-11-27. Back to the text for source 4
  5. PostgreSQL 19 Released!, PostgreSQL Global Development Group. Accessed 2026-11-27. Back to the text for source 5
  6. REPACK, PostgreSQL 19 Documentation. Accessed 2026-11-27. Back to the text for source 6
  7. Release 19, PostgreSQL Global Development Group. Accessed 2026-11-27. Back to the text for source 7
  8. pg_plan_advice, PostgreSQL 19 Documentation. Accessed 2026-11-27. Back to the text for source 8
  9. pg_plan_advice, PostgreSQL 19 Documentation. Accessed 2026-11-27. Back to the text for source 9
  10. Logical Replication, PostgreSQL 19 Documentation. Accessed 2026-11-27. Back to the text for source 10
  11. Replicating Sequences, PostgreSQL 19 Documentation. Accessed 2026-11-27. Back to the text for source 11
  12. WAIT FOR, PostgreSQL 19 Documentation. Accessed 2026-11-27. Back to the text for source 12
  13. INSERT, PostgreSQL 19 Documentation. Accessed 2026-11-27. Back to the text for source 13
  14. Query Planning, PostgreSQL 19 Documentation. Accessed 2026-11-27. Back to the text for source 14
  15. Resource Consumption, PostgreSQL 19 Documentation. Accessed 2026-11-27. Back to the text for source 15
  16. Release 19: Migration to Version 19, PostgreSQL Global Development Group. Accessed 2026-11-27. Back to the text for source 16
  17. Release 19: Migration to Version 19, PostgreSQL Global Development Group. Accessed 2026-11-27. Back to the text for source 17
  18. pg_upgrade, PostgreSQL 19 Documentation. Accessed 2026-11-27. Back to the text for source 18