PostgreSQL 19: REPACK, WAIT FOR LSN and ON CONFLICT DO SELECT, Tested Against 18

Six measured results from PostgreSQL 19.0 against 18.7
On this page

PostgreSQL 19 was released on 19 November 2026. The announcement is long, and most of it reads the way release announcements do: a list of things that are now possible. I wanted to know which of them change a design decision, so I ran them. Three containers, PostgreSQL 19.0 as a primary with a streaming standby and PostgreSQL 18.7 beside them, and eleven experiments that put the same question to both versions.

Four things came out of it that I would act on. A table can now be rewritten to reclaim space while it stays in use: during a REPACK (CONCURRENTLY) of a 746 MB table, 414 writes finished, against 5 during VACUUM FULL. A NOT IN query that took 74 seconds on 18 took 29 milliseconds on 19, with no change to the SQL. A standby that was 200 ms behind returned stale data for 199 reads out of 200, and for none once the reader used the new WAIT FOR LSN. And logical decoding started on a server at wal_level = replica with no restart, which on 18 is an error.

There is also a list of things that will bite on upgrade day: three defaults change, one authentication method is gone, and pg_upgrade refuses some clusters outright. That list is near the end, with a script that finds each item on a running 18 server.

Six measured results from PostgreSQL 19.0 against 18.7: writes finished during a table rewrite, a NOT IN query, a bulk insert with a foreign key, WAL written by get-or-create, stale reads on a standby, and logical decoding without a restart
Six results from the run, PostgreSQL 19.0 beside 18.7 on the same machine.

The test bench

Everything runs from one script on a GitHub Actions runner. It starts the official postgres:19 and postgres:18 images, copies the 19 primary with pg_basebackup to make a standby, and then a Python program runs the experiments and writes what it saw to a text file. All data is generated. The timings compare two things on the same machine minutes apart; they say nothing about your hardware.

%%{init: {'theme':'base','themeVariables':{'primaryColor':'#FFF3E0','primaryTextColor':'#232F3E','primaryBorderColor':'#FF9900','lineColor':'#232F3E','clusterBkg':'#F8FAFC','clusterBorder':'#CBD5E1','edgeLabelBackground':'#FFFFFF','nodeTextColor':'#232F3E'}}}%%
flowchart TD
    L["Lab script:
11 experiments, generated data"] --> P["PostgreSQL 19.0
primary"] P --> S["PostgreSQL 19.0 standby:
streaming, replication slot"] L --> S L --> O["PostgreSQL 18.7:
the same statements, for comparison"] L --> R["results.txt:
what each statement answered"] style L fill:#FFF3E0,stroke:#FF9900,stroke-width:2px,color:#232F3E style P fill:#EBF8FF,stroke:#0073BB,stroke-width:2px,color:#004C74 style S fill:#EBF8FF,stroke:#0073BB,stroke-width:2px,color:#004C74 style O fill:#F3E8FF,stroke:#7C3AED,stroke-width:2px,color:#4C1D95 style R fill:#F0FFF4,stroke:#1D8102,stroke-width:2px,color:#145202

One lesson arrived before the first experiment. My first standby had no replication slot. The experiments generate several gigabytes of WAL, the standby fell behind, the primary recycled a segment the standby still needed, and the standby stopped for good with requested WAL segment has already been removed. Creating the standby with a slot (pg_basebackup -C -S standby1) fixed it. Nothing about that is new in 19, and it is still the most common way to lose a replica.

REPACK

VACUUM FULL and CLUSTER both rewrite a table, and both hold an ACCESS EXCLUSIVE lock for the whole rewrite, so nothing can read or write the table until they finish. That lock is why most teams never run either on a busy table and reach for an extension such as pg_repack or pg_squeeze. PostgreSQL 19 puts one command, REPACK, in place of both, and gives it a CONCURRENTLY option. This is the tour file from the sample, statements and answers together:

SQL17 lines
select pg_size_pretty(pg_total_relation_size('invoice')) as size_before;
 size_before 
-------------
 53 MB

-- Readers and writers keep working while this runs. The table needs a primary key.
REPACK (CONCURRENTLY) invoice;
REPACK
select pg_size_pretty(pg_total_relation_size('invoice')) as size_after;
 size_after 
------------
 18 MB

-- Rewrite in the order of an index and refresh the statistics in the same pass.
-- This form takes an exclusive lock, as CLUSTER did.
REPACK (ANALYZE) invoice USING INDEX invoice_customer;
REPACK

To see what “concurrently” is worth, the lab builds a table of 2.4 million rows, deletes every second row and runs a plain VACUUM, which leaves 746 MB holding 373 MB of data. Then one session updates a row and another reads a row about every 2 ms, while a third runs the rewrite.

StatementTookWrites finished during itSlowest writeReads finished during itSlowest read
VACUUM FULL3.63 s53,641 ms213,633 ms
REPACK6.69 s106,386 ms646,579 ms
REPACK (CONCURRENTLY)6.60 s414898 ms1,839505 ms

All three took the table from 746 MB to 373 MB, and in all three every update the writer had been told was committed was in the table afterwards. The difference is the middle columns. Under VACUUM FULL and plain REPACK the slowest write and the slowest read are as long as the statement: the sessions were queued behind the lock. Under REPACK (CONCURRENTLY) they kept working, with one pause of under a second that I take to be the moment the new files are swapped in under a short exclusive lock.

Two cautions about that table. The pause was 438, 458 and 898 ms in three runs, so read it as “a fraction of a second on a table this size” and plan for longer on a larger one. And do not read the “Took” column as a ranking: in an earlier run VACUUM FULL took 12.4 s and plain REPACK 6.1 s, the opposite order. On a shared runner I could not separate the two. Plain REPACK is a new name for what you already had, and the reason to care is the option.

While the concurrent rewrite ran, the lab watched two things. effective_wal_level went from replica to logical and back, and one logical replication slot existed and then did not. The concurrent rewrite is built on logical decoding: it copies the table, then replays the changes made meanwhile. That explains the conditions the documentation sets, two of which the lab hit:

  • The table needs a primary key or an index set as its replica identity. Without one: ERROR: cannot execute REPACK (CONCURRENTLY) on relation "no_key".
  • It cannot run inside a transaction block: ERROR: REPACK (CONCURRENTLY) cannot run inside a transaction block. A migration tool that wraps every step in a transaction needs an exception for it.
  • It needs free disk for a second copy of the table and its indexes.
  • It uses a replication slot from its own pool, max_repack_replication_slots, 5 by default.
  • The documentation lists partitioned and unlogged tables as not supported, and says the rewrite is not MVCC-safe: a transaction with a snapshot older than the rewrite can see the table as empty. I did not test those three.
⚠️
LONG TRANSACTIONS

The MVCC note matters for reporting jobs and for pg_dump, which hold one snapshot for a long time. Schedule a concurrent repack so that it does not start while such a job is running against the same table, the same rule that applies to TRUNCATE and to table-rewriting forms of ALTER TABLE.

Get or create in one statement

“Give me the id for this email, creating the row if there is none” is in almost every application, and until now PostgreSQL had no clean way to write it. ON CONFLICT DO NOTHING RETURNING id returns no row when the row already exists, so it needs a second query. The usual workaround, DO UPDATE SET name = EXCLUDED.name, returns the row by rewriting it. PostgreSQL 19 adds DO SELECT:

SQL17 lines
insert into customer(email, name) values ('ada@example.test', 'Ada')
on conflict (email) do select
returning id, name, old.id as old_id, new.id as new_id;
 id | name | old_id | new_id 
----+------+--------+--------
  1 | Ada  |        |      1

INSERT 0 1
-- The same email again: nothing is written, and the existing row comes back.
insert into customer(email, name) values ('ada@example.test', 'Somebody else')
on conflict (email) do select
returning id, name, old.id as old_id, new.id as new_id;
 id | name | old_id | new_id 
----+------+--------+--------
  1 | Ada  |      1 |      1

INSERT 0 1

The second statement wrote nothing and returned the existing row with its original name. The old_id column answers a question the workaround never could: was the row created or found? RETURNING old arrived in 18; with DO SELECT it is null for a row that was inserted and filled for one that was found.

The cost of the workaround is easy to measure. One existing row, then the same statement 5,000 times:

On conflictRows returnedWAL writtenTime on 19
DO NOTHING RETURNING id022 kB1,078 ms
DO UPDATE SET name = EXCLUDED.name RETURNING id5,000850 kB2,189 ms
DO SELECT RETURNING id5,00022 kB1,080 ms

The no-op update writes a new row version and its WAL every time, 850 kB here for one unchanged row, and every one of those versions is work for vacuum and for every replica. DO SELECT writes what DO NOTHING writes and returns the row. On 18 the statement is a syntax error.

Three details from the run:

  • Concurrency. Sixteen sessions ran the statement for the same new email at the same instant. One row was created and all sixteen got its id.
  • Locking. DO SELECT FOR UPDATE locks the row that was found, for a read followed by a write in the same transaction. A WHERE clause after it filters the found row, and when the filter does not match, no row comes back, so the caller must handle an empty result.
  • Identity values. All three forms used 5,001 identity values for 5,001 calls. The default is evaluated before the conflict is found. A get-or-create on a hot path still burns through a sequence, so use bigint.

Read-your-writes on a standby

Sending reads to a standby has one well-known trap. A user saves a form, the write goes to the primary, the next page reads from a standby that has not replayed it yet, and the change appears to be lost. Teams work around it with sticky sessions, with a short “read from the primary after a write” window, or by polling the replay position. PostgreSQL 19 adds a statement for it: WAIT FOR LSN, run on the standby, returns when the standby has replayed up to a given position.

%%{init: {'theme':'base','themeVariables':{'primaryColor':'#FFF3E0','primaryTextColor':'#232F3E','primaryBorderColor':'#FF9900','lineColor':'#232F3E','signalColor':'#0073BB','signalTextColor':'#0F172A','actorBkg':'#FFF3E0','actorBorder':'#FF9900','actorTextColor':'#232F3E','noteBkgColor':'#FFF8E7','noteBorderColor':'#FF9900','noteTextColor':'#232F3E'}}}%%
sequenceDiagram
    participant A as Application
    participant P as Primary
    participant S as Standby
    A->>P: UPDATE, commit
    A->>P: SELECT pg_current_wal_flush_lsn()
    P-->>A: 2/6692CEC8
    A->>S: WAIT FOR LSN '2/6692CEC8' WITH (TIMEOUT '5s')
    Note over S: Returns when replay reaches that position
    S-->>A: success
    A->>S: SELECT the row
    S-->>A: The value just written

This is the loop from the lab. It writes on the primary, takes the position, optionally waits on the standby, reads, and counts the reads that came back stale:

Python12 lines
        def trial(label: str, wait: bool) -> None:
            stale, waits = 0, []
            for i in range(1, rounds + 1):
                primary.execute("update kv set v = %s where k = 1", [i])
                lsn = one(primary, "select pg_current_wal_flush_lsn()")
                if wait:
                    started = time.perf_counter()
                    standby.execute(f"WAIT FOR LSN '{lsn}' WITH (MODE 'standby_replay', TIMEOUT '5s')")
                    waits.append((time.perf_counter() - started) * 1000)
                stale += one(standby, "select v from kv where k = 1") != i
            extra = f", wait median {statistics.median(waits):.1f} ms, worst {max(waits):.1f} ms" if waits else ""
            say(f"{label}: {stale} of {rounds} reads on the standby did not see the write just made{extra}")
StandbyRead at onceWAIT FOR LSN firstWait, median
Keeping up, same machine1 of 200 stale0 of 200 stale0.2 ms
Applying 200 ms late199 of 200 stale0 of 200 stale200.6 ms

With both servers on one machine the standby is nearly always in time, and one read in 200 still missed. That is the worst kind of bug: rare enough to pass every test. With 200 ms of lag, set here through recovery_min_apply_delay, nearly every read is stale without the wait and none is with it, and the wait is exactly the lag.

The behaviour at the edges is what decides how to use it:

  • When the position does not arrive in time, the statement raises an error: timed out while waiting for target LSN FFFFFFFF/00000000 to be replayed. With NO_THROW it returns the text timeout and the application decides, which is the form to use in a request path.
  • On success it returns success.
  • The default mode waits for replay and only works during recovery. On a primary it fails with recovery is not in progress, so the code must know which kind of server it is talking to. The mode primary_flush worked on the primary.
  • The syntax also has standby_write and standby_flush modes. I did not test them.

The design consequence: the position has to travel with the user. Return it from the write path, keep it in the session or a cookie, and pass it to the next read. Always set a timeout, and decide what a timeout means for each read: fall back to the primary for the page that must be right, show slightly old data for the one that need not be. Without a timeout, a stalled standby turns into a pile of waiting requests.

Logical decoding without a restart

Change data capture, logical replication and several upgrade methods need wal_level = logical, and changing wal_level needs a restart. On a production primary that restart is a change request, a maintenance window and a failover rehearsal, and it is often the longest step in a CDC project. Most servers run at replica because that is the default.

StepPostgreSQL 18.7PostgreSQL 19.0
wal_level at the startreplicareplica
Create a logical replication slotERROR: logical decoding requires "wal_level" >= "logical"Created
With the slot in placewal_level replica, effective_wal_level logical
Decode an inserttable public.decode_me: INSERT: id[integer]:1 v[text]:'hello'
After dropping the sloteffective_wal_level back to replica

On 19 the server raises its own WAL level when the first logical slot is created and lowers it when the last one goes. No setting changed and nothing restarted. The new read-only setting effective_wal_level reports what is in force, and it is the one monitoring should read from now on.

Two things follow. A CDC connector can be attached to a 19 server at replica without a window. And WAL volume can now rise because somebody created a slot, with no configuration change to explain it: logical decoding writes more WAL per change. Creating a slot needs the REPLICATION attribute, so review who holds it, and alert on logical slots that exist and are not being read, because an abandoned slot holds WAL until the disk fills. That risk is old; what is new is that it no longer takes a restart to get there.

Planner changes

Three changes in the planner need no change to the application. The first is the one I would look for in my own slow-query log.

NOT IN (subquery) has always been a trap in PostgreSQL. Because of how SQL treats NULL, the planner could not turn it into an anti-join, so it ran the subquery as a filter, and once the subquery result outgrew work_mem it rescanned the result for every outer row. The lab has 5,000 orders and 300,000 blocked customers, both columns NOT NULL, and asks for the orders whose customer is not in the blocked list.

VersionTimePlan
18.774,236 msSeq Scan on orders, filter NOT (ANY (customer_id = (SubPlan 1).col1))
19.029 msHash Right Anti Join
19.0, after DROP NOT NULL on orders.customer_idnot timedthe subplan filter again

The third row is the condition. The planner makes the conversion only when it can prove no NULLs are involved, and here that proof came from the NOT NULL constraints. Remove one and the old plan is back. So the advice does not change for new code, write NOT EXISTS, and the fix for old code after the upgrade is often a constraint that should have been there anyway. Queries written by ORMs and reporting tools are where this will show up.

The second change is aggregation before a join. Summing 2,000,000 fact rows by a column of a 1,000-row dimension table, 19 aggregates the facts by the join key first and joins 1,000 partial results instead of 2,000,000 rows:

Text11 lines
    Finalize GroupAggregate
      Group Key: d.region
      ->  Sort
            Sort Key: d.region
            ->  Hash Join
                  Hash Cond: (f.dim_id = d.id)
                  ->  Partial HashAggregate
                        Group Key: f.dim_id
                        ->  Seq Scan on fact f
                  ->  Hash
                        ->  Seq Scan on dim d

With enable_eager_aggregate on, the default, the median of three runs was 333 ms; with it off, 519 ms, with a single aggregate above the join. Parallel query was turned off for this comparison to keep the plans readable.

The third is foreign key checks. The announcement says bulk inserts into tables with foreign keys were nearly twice as fast in the project’s testing. Inserting 1,000,000 rows that each point at one of 100,000 parents:

VersionWith the foreign keyWithout itCost of the check
18.75,715 ms733 ms4,982 ms
19.02,705 ms720 ms1,985 ms

18 took 2.11 times as long as 19, and the ratio was between 1.96 and 2.11 in four runs. The check still costs about three times the insert itself, so dropping constraints for a bulk load remains a real trade, with a smaller prize than before.

Plan advice

PostgreSQL has never had query hints in core. Version 19 ships two modules that come close, and they are worth understanding before somebody on the team finds them. pg_plan_advice describes a plan as a short text and accepts the same text back as an instruction. EXPLAIN (PLAN_ADVICE) prints the advice for the plan the planner chose:

Text18 lines
the planner's own choice, with EXPLAIN (COSTS OFF, PLAN_ADVICE):
    Hash Join
      Hash Cond: (f.dim_id = d.id)
      ->  Seq Scan on join_fact f
      ->  Hash
            ->  Seq Scan on join_dim d
    Generated Plan Advice:
      JOIN_ORDER(f d)
      HASH_JOIN(d)
      SEQ_SCAN(f d)
      NO_GATHER(f d)
with pg_plan_advice.advice = 'MERGE_JOIN_PLAIN(d)':
    Merge Join
      Merge Cond: (f.dim_id = d.id)
      ->  Index Scan using join_fact_dim on join_fact f
      ->  Index Scan using join_dim_pkey on join_dim d
    Supplied Plan Advice:
      MERGE_JOIN_PLAIN(d) /* matched */

Setting pg_plan_advice.advice to MERGE_JOIN_PLAIN(d) turned the hash join into a merge join over the two indexes, and EXPLAIN reported the advice as matched. A longer string fixed the join order, the join method and the index together. Advice that named an index that does not exist was reported as matched, inapplicable, failed, and the query ran with the planner’s own plan. Bad advice did not break the query.

The second module, pg_stash_advice, attaches advice to a query id so the application does not change. The lab created a stash with pg_create_advice_stash('lab'), stored advice for the query’s id with pg_set_stashed_advice, and set pg_stash_advice.stash_name. The same query text then produced:

Text7 lines
with pg_stash_advice.stash_name = 'lab', the same query, nothing else set:
    Merge Join
      Merge Cond: (f.dim_id = d.id)
      ->  Index Scan using join_fact_dim on join_fact f
      ->  Index Scan using join_dim_pkey on join_dim d
    Supplied Plan Advice:
      MERGE_JOIN_PLAIN(d) /* matched */

That is a production tool: a plan regression at two in the morning can be pinned without a deployment. It is also a way to collect plans that nobody remembers pinning. Treat each stashed entry as a change with an owner and a review date, because advice outlives the data distribution that justified it. In the lab the module was loaded per session with LOAD; I did not test it through shared_preload_libraries, and I did not test how advice behaves across a major version upgrade.

Changed defaults

A major version that changes defaults changes behaviour for everybody who never set them. These are the settings as the two servers reported them, untouched:

Setting18.719.0
jitonoff
default_toast_compressionpglzlz4
max_locks_per_transaction64128
io_workers3removed
io_min_workers / io_max_workersnot there2 / 8
effective_wal_levelnot therereplica
max_repack_replication_slotsnot there5
autovacuum_max_parallel_workersnot there0
password_expiration_warning_thresholdnot there604800 (seven days)
  • JIT is off. The release notes say the cost model that decided when to compile was unreliable. For transaction processing this removes a known source of sudden slow queries. A warehouse that runs large analytical queries and benefited from JIT must now turn it on, and should measure before and after.
  • TOAST compression is lz4. It applies to values written after the change; existing values stay as they are. Measured below.
  • Lock table size. The default doubles, and the release notes say the allocation changed so that a setting must be doubled to keep the capacity it had. If you raised max_locks_per_transaction for a schema with many partitions, carry over twice your number, not your number.
  • I/O workers. io_workers is gone and the pool now sizes itself between io_min_workers and io_max_workers. A configuration file that still sets io_workers needs editing before the first start.
  • Parallel autovacuum exists and is off: autovacuum_max_parallel_workers is 0.

For the compression change I stored 20,000 documents of about 17 kB of repetitive JSON-like text, once with each method, on 19:

CompressionInsertRead every documentSize on disk
pglz3,451 ms310 ms31 MB for 297 MB of text
lz41,886 ms299 ms39 MB for 297 MB of text

lz4 nearly halved the insert time, read at the same speed, and used a quarter more disk. For most systems that is the right trade and the reason for the new default. Where storage is the cost that matters, for example a large archive of documents that are written once, set pglz on those columns and keep it by choice. The text here compresses unusually well; measure with your own documents.

Upgrade checks

The release notes list 22 incompatibilities. Most are narrow. The ones below can stop an upgrade or change behaviour silently, and each can be found on the old server with a query. The sample has a script, sql/upgrade-checks.sql, and this is its first half:

SQL19 lines
\echo 1. Roles that still have an MD5 password: 19 warns after every such login
select rolname from pg_authid where rolpassword like 'md5%' order by 1;

\echo 2. pg_hba.conf lines that use RADIUS: removed in 19
select line_number, type, database, user_name, address
from pg_hba_file_rules where auth_method = 'radius';

\echo 3. Settings that 19 removes or forces, set in a file or on the command line
select name, setting, source from pg_settings
where name in ('io_workers', 'standard_conforming_strings', 'escape_string_warning')
  and source <> 'default';

\echo 3b. The same settings, attached to a role or a database
select coalesce(r.rolname, '(every role)') as role, coalesce(d.datname, '(every database)') as database, c.setting
from pg_db_role_setting s
left join pg_roles r on r.oid = s.setrole
left join pg_database d on d.oid = s.setdatabase
cross join lateral unnest(s.setconfig) as c(setting)
where c.setting ~ '^(io_workers|standard_conforming_strings|escape_string_warning)=';

To show that each check finds what it looks for, the run first plants one of everything on the 18 server, then runs the script. All eight checks reported their planted item. What they cover:

CheckWhat 19 does
Roles with an MD5 passwordWarns after every successful login. MD5 was deprecated in 18. Reset those passwords under scram-sha-256 before the upgrade.
pg_hba.conf lines with radiusRADIUS authentication is removed. A server with such a line needs another method first.
io_workers, standard_conforming_strings, escape_string_warning set anywhereThe first and third are removed. standard_conforming_strings is forced on, and a dump made by an older pg_dump with it off will not load correctly.
Defaults for jit, default_toast_compression, max_locks_per_transactionChange as in the table above, wherever the source is default.
Databases in MULE_INTERNALThe encoding is removed. Dump and restore in another encoding.
Role, database or tablespace names with a line breakNo longer allowed, and pg_upgrade refuses the cluster.
btree_gist indexes on inet or cidrpg_upgrade refuses the cluster. The release notes call those operator classes broken: they can leave out rows that should be returned. Rebuild the indexes without them.
Indexes on full text search or pg_trgmReindex after pg_upgrade, and recompute stored tsvector values, when the database uses the ICU or builtin locale provider.

Three more from the notes that no query finds. json_array() over a subquery with no rows now returns [], where 18 returned NULL; the lab confirmed both, and any code that tests the result for NULL changes behaviour. In pg_stat_subscription_stats the column sync_error_count is now sync_table_error_count, and several buffer wait events were renamed, so check dashboards and alert rules. And a parallel VACUUM with cost-based delay now shares one budget between its workers, so it may run slower than before.

Upgrade checklist for PostgreSQL 19: defaults that change (jit, TOAST compression, lock table size, I/O workers) and things that are removed or refused (RADIUS, MULE_INTERNAL, standard_conforming_strings off, btree_gist indexes on inet and cidr, names with line breaks, MD5 warning)
What changes without being asked, and what stops an upgrade.

Smaller SQL additions

Four additions that remove code people write by hand. Each is a syntax error or a missing function on 18.7; the lab ran each of them against both versions.

SQL29 lines
-- 3. Carry the last known reading forward
select ts, reading, last_value(reading) ignore nulls over (order by ts) as carried
from (values (1, 20), (2, null), (3, null), (4, 23), (5, null)) as t(ts, reading);
 ts | reading | carried 
----+---------+---------
  1 |      20 |      20
  2 |         |      20
  3 |         |      20
  4 |      23 |      23
  5 |         |      23

-- 4. A query straight to a JSON array
copy (select id, email, name from customer) to stdout (format json, force_array);
[
 {"id":1,"email":"ada@example.test","name":"Ada"}
]
-- 5. A random date in a range, for test data
select bool_and(d between date '2026-01-01' and date '2026-12-31') as all_in_range, count(distinct d) > 100 as varied
from (select random(date '2026-01-01', date '2026-12-31') as d from generate_series(1, 1000)) s;
 all_in_range | varied 
--------------+--------
 t            | t

-- 6. String methods inside a JSON path
select jsonb_path_query('{"name": "  Ada Lovelace  "}', '$.name.btrim().upper()') as name,
       jsonb_path_query('"2026-11-19"', '$.split_part("-", 1)') as year;
      name      |  year  
----------------+--------
 "ADA LOVELACE" | "2026"

IGNORE NULLS in window functions is the most widely useful of the four. Carrying the last known value forward over gaps, in sensor readings or in any sparse time series, used to take a subquery with a running count to form groups. COPY ... (FORMAT json) writes a query result as JSON on the server, one object per line, or as one array with FORCE_ARRAY, which replaces a small export script.

New views

Four things to add to a monitoring setup, all seen in the run:

  • pg_stat_lock counts lock waits by lock type. After the repack experiment it held one line: relation, 4 waits, 20,187 ms. That is the queue behind VACUUM FULL and plain REPACK, now visible after the fact without sampling pg_locks at the right moment. The waits behind the concurrent form, all under a second, were not counted, so the view appears to record only waits above a threshold. I did not confirm which.
  • pg_stat_autovacuum_scores shows why autovacuum will or will not visit a table: a score for vacuum, for analyze and for wraparound, and the decisions do_vacuum and do_analyze. After the bulk inserts the lab’s tables showed an analyze score in the tens of thousands and a vacuum score of zero. This replaces the arithmetic everybody does by hand with thresholds and scale factors.
  • pg_stat_recovery on a standby gives the replay position and pause state in one row.
  • EXPLAIN (ANALYZE, IO) adds read-ahead and asynchronous I/O figures to each scan, per worker.
Text16 lines
    Finalize Aggregate (actual rows=1.00 loops=1)
      Buffers: shared read=12739
      ->  Gather (actual rows=3.00 loops=1)
            Workers Planned: 2
            Workers Launched: 2
            Buffers: shared read=12739
            ->  Partial Aggregate (actual rows=1.00 loops=3)
                  Buffers: shared read=12739
                  ->  Parallel Seq Scan on fact (actual rows=666666.67 loops=3)
                        Prefetch: avg=22.05 max=32 capacity=94
                        I/O: count=1692 waits=14 size=7.53 in-progress=3.18
                        Buffers: shared read=12739
                        Worker 0:  Prefetch: avg=27.25 max=31 capacity=94
                          I/O: count=520 waits=5 size=7.29 in-progress=4.07
                        Worker 1:  Prefetch: avg=11.55 max=15 capacity=94
                          I/O: count=565 waits=4 size=7.27 in-progress=1.73

Recommendation

Start testing now and do not put 19.0 under a system of record yet. The cautious practice with PostgreSQL is to take a new major version into production after its first or second minor release, and nothing here argues against it. REPACK (CONCURRENTLY) in particular is new machinery built on logical decoding that rewrites live tables; it did everything right in this lab, and one lab is not a track record.

What I would do in the meantime:

  • Run the upgrade checks on every 18 cluster this month. The MD5, RADIUS and btree_gist items take time to fix and none of them needs 19 to start.
  • Put 19 in the CI matrix. The official image is there. The json_array() change and the JIT default are the kind of difference a test suite finds in an afternoon.
  • Replay the slow-query log. Look for NOT IN and for aggregates over joins. Those are the free gains, and they tell you how much the upgrade is worth.
  • Decide where each feature goes. DO SELECT and IGNORE NULLS are application changes that can only ship once every environment is on 19. WAIT FOR LSN needs a place to carry the position between requests, which is a design task to start now.
  • Plan the first concurrent repack on a table you can lose. Check the primary key, the free disk and the long-running readers first.

If your PostgreSQL is a managed service, the provider sets the date. Each service adds a new major version on its own schedule, and extensions follow at their own pace. I compared two such services last week in Azure HorizonDB or Azure Database for PostgreSQL Flexible Server; neither ran 19 at that point.

For healthcare and other regulated workloads, two of these changes deserve a line in the validation plan. The standby pattern with WAIT FOR LSN removes a class of “the record I just saved is missing” defects, which in a clinical system is a patient-safety matter and not a cosmetic one. And any table rewrite of clinical data, concurrent or not, should be followed by the same row-count and checksum reconciliation you would run after a migration.

📝
HOW THIS WAS CHECKED

Everything in this article marked as measured comes from GitHub Actions run 45189048112 of 23 November 2026, on the official postgres:19 (19.0) and postgres:18 (18.7) images on one hosted runner; the output files are on the ci-results-postgresql-19-first-look branch of the sample repository. All eleven experiments, the SQL tour and the eight upgrade checks completed without error. Three earlier runs the same day were used for the ranges quoted. Timings are single-machine comparisons with a median of three where stated; the repack figures are one run each. Not done: pg_upgrade was not run, so the items it refuses are taken from the release notes and only the detection queries were tested; REPACK (CONCURRENTLY) was not tested on partitioned or unlogged tables, under a long-running snapshot, or with a failure in the middle; the standby_write and standby_flush modes of WAIT FOR LSN, the new logical replication options, SNI, parallel autovacuum and the I/O worker settings were not tested; no managed service was tested; nothing here is a benchmark of absolute performance.

References & Further Reading


Discover more from C4: Container, Code, Cloud & Context

Subscribe to get the latest posts sent to your email.

Written by

Nithin Mohan TK

Hello Namaste! 👋🏻 I'm an accomplished Enterprise Solution Architect & Engineering Leader with 20+ years of progressive experience architecting, building, and scaling transformative enterprise solutions. ⚜️ Solution Architect / AI & Cloud 📌 Galway, Ireland

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.