Back to all posts

PostgreSQL 19: Three Defaults That Decide Your Upgrade

2026-11-22
luodaInt
PostgreSQL 19: Three Defaults That Decide Your Upgrade

PostgreSQL 19: Three Defaults That Decide Your Upgrade

PostgreSQL 19 shipped on 19 November 2026. The release notes lead with features: a new REPACK command, WAIT FOR LSN for read-your-writes on standbys, and a long list of planner changes. For a team that runs the database rather than reads its changelog, the urgent items are three defaults that change what an unchanged configuration means. None of them produces a syntax error. They surface as a slow query, a lock error under load, or an upgrade that stops before it starts.

1. JIT is off, and the old trigger is still there

JIT compiles parts of query execution to native code through LLVM: expression evaluation in WHERE clauses, target lists, aggregates and projections, plus tuple deforming. The documentation says it helps "primarily for long-running CPU-bound queries", and that for short queries "the added overhead of performing JIT compilation will often be higher than the time it can save" (Chapter 30).

The old mechanism did not ask how long a query actually runs. It compared the plan's estimated cost with jit_above_cost (default 100000), then used jit_inline_above_cost and jit_optimize_above_cost (both 500000) for the more expensive work. Estimated cost is not execution time. A few more inserts, or a change in row estimates as a table grows, can push a query that finishes in milliseconds over the line, and from then on every execution pays the compile step. The release notes give the reason directly: that costing "has been determined to be unreliable", and sites "doing many large analytical queries" now have to enable JIT manually (release notes).

Three practical consequences:

  • The threshold did not move. Only jit changed, from on to off. If you re-enable JIT, it still fires at a cost of 100000 unless you move the thresholds too.
  • An explicit setting survives. If postgresql.conf, an ALTER SYSTEM entry, or an ALTER ROLE or ALTER DATABASE setting says jit = on, the upgrade keeps it. Check the value rather than the version:
SHOW jit;
SELECT name, setting, source FROM pg_settings WHERE name = 'jit';
  • Opt in where it paid. A reporting role or a warehouse database can carry the setting without putting the compile cost back on OLTP traffic:
ALTER ROLE reporting SET jit = on;
ALTER ROLE reporting IN DATABASE warehouse SET jit = on;
ALTER DATABASE warehouse SET jit = on;

One detail for anyone checking whether the build supports JIT at all: pg_jit_available() returns true only when a JIT provider is installed and jit is on (docs). On a fresh 19 server with the new default it returns false even on an LLVM build, so set jit = on in the session before using it as a build check.

The decision was not unanimous in its details. On pgsql-hackers, Pierre Ducroquet proposed disabling only jit_tuple_deforming instead of all of JIT, arguing that would remove most of the problem cases, such as queries across many partitions and tables that had columns added or moved. Tomas Vondra replied that the reports he found had timings dominated by optimization and emission, that disabling only deforming risked a half fix, and that the wider change was the safer default. The shipped change is the wider one. The counter-argument still makes a good checklist for your own workload: if you re-enable JIT, measure the long analytical queries rather than trusting the release note.

The decision is also made at plan time, so a prepared statement using a generic plan keeps the settings in effect when it was prepared, not when it runs. In a pooled application, change the setting, recycle the connections, and watch plan behavior as well as the server variable.

2. A lock slot now buys half as much

max_locks_per_transaction sets how many objects each server process or prepared transaction can lock at once. It is not a row limit. PostgreSQL 19 raises the default from 64 to 128, and the release notes explain why: "Lock size allocation has changed, so effectively settings must now be doubled to match their capacity in previous releases."

That sentence matters more than the new default. A cluster that never set the parameter gets 128 and roughly the old capacity. A cluster that pinned 64 in postgresql.conf or through ALTER SYSTEM keeps 64, and in 19 that holds half the objects it held in 18. The failure mode appears under partition-heavy queries as a lock table error, which reads like a load problem rather than a configuration change.

Check the primary and every standby. The parameter can only be set at server start, and a standby must carry the same or a higher value than its primary or queries are refused there (lock management).

SHOW max_locks_per_transaction;
SELECT name, setting, source FROM pg_settings
WHERE name = 'max_locks_per_transaction';

If source says default, the upgrade gives you the new value. If it names a file, a command line, or an override, double the number yourself.

3. One refusal at pg_upgrade, one dump that will not load

btree_gist indexes on inet and cidr. The release notes call the btree_gist opclasses for these types broken "because they can exclude rows that should be returned". The default opclasses change to GiST, and pg_upgrade "will disallow upgrading of clusters with btree_gist inet/cidr indexes". Before the upgrade those indexes can return wrong answers without an error. During it, they stop the upgrade.

Find them:

SELECT ic.relname AS index_name,
       t.relname AS table_name,
       opc.opcname,
       n.nspname AS opclass_schema
FROM pg_index i
JOIN pg_class ic ON ic.oid = i.indexrelid
JOIN pg_class t ON t.oid = i.indrelid
JOIN pg_opclass opc ON opc.oid = ANY(i.indclass)
JOIN pg_namespace n ON n.oid = opc.opcnamespace
WHERE opc.opcname IN ('gist_inet_ops', 'gist_cidr_ops')
  AND n.nspname <> 'pg_catalog';

Rows here point at an opclass defined outside pg_catalog, which is the extension case the upgrade refuses. Rebuild each index with the new default opclass, using CREATE INDEX CONCURRENTLY on a live table so writes are not blocked, then drop the old index.

Dumps taken with standard_conforming_strings = off. The server now forces that setting on, and the release notes say a dump created by a pre-19 pg_dump or pg_dumpall with the setting off "will not properly load into PostgreSQL 19 and later servers". Take the dump with the 19 client tools, or confirm the setting was on when the dump was made.

If the database uses a locale provider other than libc, the release notes make one more recommendation: reindex indexes that use full text search or pg_trgm, and recompute stored tsvector values, because character classification now comes from the database's locale provider instead of libc.

What the upgrade buys

REPACK (CONCURRENTLY) reclaims space and can reorder a table to match an index without blocking reads and writes. It replaces VACUUM FULL and CLUSTER, both kept for compatibility. For a team that used to schedule downtime for a full rewrite of a bloated table, that changes operations, not just benchmark numbers.

WAIT FOR LSN gives an application read-your-writes on a standby. Store the LSN after the commit on the primary, then wait on the replica:

WAIT FOR LSN '0/0306EE20' WITH (MODE 'standby_replay', TIMEOUT '100ms', NO_THROW);

It returns success, timeout, or not in recovery. The constraints are in the command docs: it must run as a top-level command, it cannot run inside a function or a transaction that already holds a snapshot, and the standby modes only work during recovery. With NO_THROW the transaction stays usable after a timeout, which is the case a read path needs to handle anyway.

A short runbook

  1. Record the current values and where they come from:
SELECT name, setting, source FROM pg_settings
WHERE name IN ('jit', 'max_locks_per_transaction');
  1. Decide JIT per workload, then set it for roles or databases instead of globally.
  2. Double an explicit lock setting, and match every standby.
  3. Clear btree_gist inet and cidr indexes before pg_upgrade sees them.
  4. Take the dump with the 19 client tools.
  5. Run the upgrade on a copy with production-sized data, then compare the slow query log, not just whether the server started.

The part that runs without a migration

Defaults are the part of a major release that changes behavior with no SQL to review. Two of these change what your existing configuration means, and the third stops the upgrade outright. All three are cheap to check before a maintenance window and expensive to discover after it.

If you are planning a database upgrade and want the checks reviewed before the window opens, get in touch.