PostgreSQL 19 is released on November 19, 2025. The majority of the PostgreSQL 19 features were reverted before this release. We can expect those reverted features in the upcoming release of PostgreSQL version 20. But anyway, this release contains some features that were very useful for the database administrators and database developers that help the maintenance activities and administration activities inside postgres database.
We can download the postgres 19 branch source using the link below
git clone https://github.com/postgres/postgres.git -b REL_19_STABLE
You can also check the new features that come with postgresql version 19 from their official Release notes.
Now, let’s look at the most important features of PostgreSQL 19.
- REPACK CONCURRENTLY.
- Parallel autovacuum.
- New scoring system for autovacuum.
- Pg_plan_advice extension.
- Pg_stash_advice extension.
- Logical replication improvements.
Let’s look in more detail at the REPACK CONCURRENTLY feature
In postgres 19, we have a new command named REPACK.
We can check this command metadata in psql like this:
postgres=# \h repack
Result:
Command: REPACK
Description: rewrite a table to reclaim disk space
Syntax:
REPACK [ ( option [, ...] ) ] [ table_and_columns [ USING INDEX [ index_name ] ] ]
REPACK [ ( option [, ...] ) ] USING INDEX
where option can be one of:
VERBOSE [ boolean ]
ANALYZE [ boolean ]
CONCURRENTLY [ boolean ]
and table_and_columns is:
table_name [ ( column_name [, ...] ) ]
URL: https://www.postgresql.org/docs/19/sql-repack.html
Based on PostgreSQL, the updated values are not removed from the database. It needs VACUUM FULL or VACUUM to be completely removed from this database. But in a large production database, VACUUM and VACUUM FULL will hold locks on those tables, and during that time we cannot execute operations like UPDATE or DELETE.
In PostgreSQL, this issue can be easily solved by the introduction of the repack command. Before PostgreSQL 19, the solution for this issue was to use the pg_repack command.
Now, we can use the repack command normally and with concurrent mode also.
We also have a new live tracking view for tracking the progress of repacking named pg_stat_progress_repack.
We can also check this view definition like this.
postgres=# \d+ pg_stat_progress_repack
Result:
View "pg_catalog.pg_stat_progress_repack"
Column | Type | Collation | Nullable | Default | Storage | Description
----------------------+---------+-----------+----------+---------+----------+-------------
pid | integer | | | | plain |
datid | oid | | | | plain |
datname | name | | | | plain |
relid | oid | | | | plain |
command | text | | | | extended |
phase | text | | | | extended |
repack_index_relid | oid | | | | plain |
heap_tuples_scanned | bigint | | | | plain |
heap_tuples_inserted | bigint | | | | plain |
heap_tuples_updated | bigint | | | | plain |
heap_tuples_deleted | bigint | | | | plain |
heap_blks_total | bigint | | | | plain |
heap_blks_scanned | bigint | | | | plain |
index_rebuild_count | bigint | | | | plain |
View definition:
SELECT s.pid,
s.datid,
d.datname,
s.relid,
CASE s.param1
WHEN 1 THEN 'CLUSTER'::text
WHEN 2 THEN 'REPACK'::text
WHEN 3 THEN 'VACUUM FULL'::text
ELSE NULL::text
END AS command,
CASE s.param2
WHEN 0 THEN 'initializing'::text
WHEN 1 THEN 'seq scanning heap'::text
WHEN 2 THEN 'index scanning heap'::text
WHEN 3 THEN 'sorting tuples'::text
WHEN 4 THEN 'writing new heap'::text
WHEN 5 THEN 'catch-up'::text
WHEN 6 THEN 'swapping relation files'::text
WHEN 7 THEN 'rebuilding index'::text
WHEN 8 THEN 'performing final cleanup'::text
ELSE NULL::text
END AS phase,
s.param3::oid AS repack_index_relid,
s.param4 AS heap_tuples_scanned,
s.param5 AS heap_tuples_inserted,
s.param6 AS heap_tuples_updated,
s.param7 AS heap_tuples_deleted,
s.param8 AS heap_blks_total,
s.param9 AS heap_blks_scanned,
s.param10 AS index_rebuild_count
FROM pg_stat_get_progress_info('REPACK'::text) s(pid, datid, relid, param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11, param12, param13, param14, param15, param16, param17, param18, param19, param20)
LEFT JOIN pg_database d ON s.datid = d.oid;
The next feature is parallel workers for autovacuum.
We can set the number of parallel workers for the autovacuum process like this.
Before setting a new value, check the current value.
show autovacuum_max_parallel_workers ;
Result:
autovacuum_max_parallel_workers
---------------------------------
0
(1 row)
Check the metadata of this parameter from pg_settings like this.
postgres=# select * from pg_settings where name = 'autovacuum_max_parallel_workers';
Result:
-[ RECORD 1 ]---+-----------------------------------------------------------------------------------
name | autovacuum_max_parallel_workers
setting | 0
unit |
category | Vacuuming / Automatic Vacuuming
short_desc | Maximum number of parallel workers that can be used by a single autovacuum worker.
extra_desc |
context | sighup
vartype | integer
source | default
min_val | 0
max_val | 1024
enumvals |
boot_val | 0
reset_val | 0
sourcefile |
sourceline |
pending_restart | f
In postgres, we can set the number of workers for the autovacuum process. We can set the number of workers based on our needs.
postgres=# show autovacuum_max_workers ;
Result:
-[ RECORD 1 ]----------+--autovacuum_max_workers | 3
Check this parameter metadata from pg_settings like this.
postgres=# select * from pg_settings where name = 'autovacuum_max_workers';
Result:
-[ RECORD 1 ]---+-------------------------------------------------------------------------------
name | autovacuum_max_workers
setting | 3
unit |
category | Vacuuming / Automatic Vacuuming
short_desc | Sets the maximum number of simultaneously running autovacuum worker processes.
extra_desc |
context | sighup
vartype | integer
source | default
min_val | 1
max_val | 262143
enumvals |
boot_val | 3
reset_val | 3
sourcefile |
sourceline |
pending_restart | f
In postgresql, by default, we have a background worker related to autovacuum, and we can see that worker's statistics from pg_stat_activity like this.
postgres=# select * from pg_stat_activity where wait_event = 'AutovacuumMain';
Result:
-[ RECORD 1 ]----+---------------------------------
datid |
datname |
pid | 317568
leader_pid |
usesysid |
usename |
application_name |
client_addr |
client_hostname |
client_port |
backend_start | 2026-11-20 11:27:49.273762+05:30
xact_start |
query_start |
state_change |
wait_event_type | Activity
wait_event | AutovacuumMain
state |
backend_xid |
backend_xmin |
query_id |
query |
backend_type | autovacuum launcher
From postgres version 13 to version 18, we can manually execute the vacuum process using parallel workers based on our needs. But there is no option for setting the parallel workers for autovacuum. But in postgresql 19, we have the option to set the parallel workers for autovacuum.
New scoring system for autovacuum.
In postgres 19, we have a new scoring system for the prioritization of autovacuum.
postgres=# select * from pg_stat_autovacuum_scores limit 10;
Result:
relid | schemaname | relname | score | xid_score | mxid_score | vacuum_score | vacuum_insert_score | analyze_score | do_vacuum | do_analyze | for_wraparound
-------+------------+-------------------+---------------------+-----------+------------+--------------+---------------------+---------------------+-----------+------------+----------------
16402 | pg_toast | pg_toast_16395 | 3e-08 | 3e-08 | 0 | 0 | 0 | 0 | f | f | f
16395 | public | employee_big | 2.5e-08 | 2.5e-08 | 0 | 0 | 0 | 0 | f | f | f
16412 | pg_toast | pg_toast_16406 | 1.5e-08 | 1.5e-08 | 0 | 0 | 0 | 0 | f | f | f
16406 | public | employee_big_copy | 1e-08 | 1e-08 | 0 | 0 | 0 | 0 | f | f | f
2619 | pg_catalog | pg_statistic | 0.016 | 1.25e-07 | 0 | 0 | 0.016 | 0 | f | f | f
1247 | pg_catalog | pg_type | 0.03518029997679644 | 1.25e-07 | 0 | 0 | 0.004 | 0.03518029997679644 | f | f | f
2836 | pg_toast | pg_toast_1255 | 1.25e-07 | 1.25e-07 | 0 | 0 | 0 | 0 | f | f | f
4171 | pg_toast | pg_toast_1247 | 1.25e-07 | 1.25e-07 | 0 | 0 | 0 | 0 | f | f | f
2830 | pg_toast | pg_toast_2604 | 1.25e-07 | 1.25e-07 | 0 | 0 | 0 | 0 | f | f | f
2832 | pg_toast | pg_toast_2606 | 1.25e-07 | 1.25e-07 | 0 | 0 | 0 | 0 | f | f | f
(10 rows)
Based on the records from this table, the autovacuum worker decides the priority of executing autovacuum on the tables.
Pg_plan_advice extension.
In postgresql 19, we have a new extension named pg_plan_advice. We can use this extension to generate better plan advice for the query from the optimizer.
We need to set this extension name in the parameter named shared_preload_libraries like this:
show shared_preload_libraries ;
Result:
shared_preload_libraries
------------------------------------------
pg_plan_advice,pg_stat_statements,hypopg
(1 row)
Now, check this extension’s parameters from pg_settings by using the query below.
postgres=# select name,category,short_desc, context from pg_settings where name ilike '%pg_plan%';
Result:
name | category | short_desc | context
-----------------------------------------------+--------------------+------------------------------------------------------------------------------+---------
pg_plan_advice.advice | Customized Options | advice to apply during query planning | user
pg_plan_advice.always_explain_supplied_advice | Customized Options | EXPLAIN output includes supplied advice even without EXPLAIN (PLAN_ADVICE) | user
pg_plan_advice.always_store_advice_details | Customized Options | Generate advice strings even when seemingly not required | user
pg_plan_advice.feedback_warnings | Customized Options | Warn when supplied advice does not apply cleanly | user
pg_plan_advice.trace_mask | Customized Options | Emit debugging messages showing the computed strategy mask for each relation | user
(5 rows)
By using the functionalities and these parameters provided by this extension, we can get better query advice from optimizer.
Example:
EXPLAIN (COSTS OFF, PLAN_ADVICE)
SELECT * FROM emp e JOIN dept d ON d.id = e.dept_id;
Result:
QUERY PLAN
---------------------------------
Hash Join
Hash Cond: (e.dept_id = d.id)
-> Seq Scan on emp e
-> Hash
-> Seq Scan on dept d
Generated Plan Advice:
JOIN_ORDER(e d)
HASH_JOIN(d)
SEQ_SCAN(e d)
NO_GATHER(e d)
(10 rows)
Pg_stash_advice extension
This is the other extension newly introduced in postgres version 19, and this extension is mainly used to store query advice, and after that, when the query is executed, then it will automatically executes based on the plan we stored earlier.
Create the extension
create extension pg_stash_advice ;
Parameters related to this extension.
postgres=# select name,category,short_desc, context from pg_settings where name ilike '%pg_stash%';
name | category | short_desc | context
----------------------------------+--------------------+------------------------------------------------------+---------
pg_stash_advice.persist_interval | Customized Options | Interval between advice stash saves, in seconds. | sighup
pg_stash_advice.stash_name | Customized Options | Name of the advice stash to be used in this session. | user
(2 rows)
Functionality of this extension.
postgres=# \dx+ pg_stash_advice
Result:
Objects in extension "pg_stash_advice"
Object description
--------------------------------------------------
function pg_create_advice_stash(text)
function pg_drop_advice_stash(text)
function pg_get_advice_stash_contents(text)
function pg_get_advice_stashes()
function pg_set_stashed_advice(text,bigint,text)
function pg_start_stash_advice_worker()
(6 rows)
We need to enable the background worker for the advice stashing.
Use the query below to enable the bgworker related to the stash advice extension.
Check the connections in pg_stat_activity before enabling the bgworker.
postgres=# select count(*) from pg_stat_activity ;
Result:
count
-------
12
(1 row)
Now, enable the bgworker.
postgres=# select pg_start_stash_advice_worker();
Result:
pg_start_stash_advice_worker ------------------------------ (1 row)
Check the count again.
postgres=# select count(*) from pg_stat_activity ;
Result:
count
-------
13
(1 row)
Check the metadata from pg_settings based on this bgworker.
postgres=# select * from pg_stat_activity where backend_type ilike '%pg_stash_advice%';
Result:
-[ RECORD 1 ]----+---------------------------------
datid |
datname |
pid | 1398757
leader_pid |
usesysid | 10
usename | postgres
application_name |
client_addr |
client_hostname |
client_port |
backend_start | 2026-11-21 14:29:16.087515+05:30
xact_start |
query_start |
state_change |
wait_event_type |
wait_event |
state |
backend_xid |
backend_xmin |
query_id |
query |
backend_type | pg_stash_advice worker
The main purpose of this extension is to store advice that improves the performance of the query. By combining the usage of these two extensions, we can provide the planner with a better plan for executing queries based on our needs.
Logical replication improvements.
Some logical replication improvements come in postgresql 19.
The first one is that we can enable logical replication without restarting the postgres server. Before postgres version 19, the default value of the parameter named wal_level is replica.
To set up logical replication in PostgreSQL, need to set the wal_level to logical, and it requires the server restart because this parameter context is postmaster. But in postgres 19, when we create a logical replication, the value of this parameter is automatically changed from replica to logical.
Actually, there are no parameters related to this in postgresql
wal_level - The value we set for postgres to use.
Effective_wal_level - The current wal level postgres is using.
Check the default value of this parameter.
postgres=# SHOW effective_wal_level;
Result:
effective_wal_level
---------------------
replica
(1 row)
Create a sample slot.
postgres=# SELECT * FROM pg_create_logical_replication_slot(
'test_slot',
'pgoutput'
);
Result:
slot_name | lsn
-----------+------------
test_slot | 0/17723200
(1 row)
Now, check the value again.
postgres=# SHOW effective_wal_level;
Result:
effective_wal_level
---------------------
logical
(1 row)
Now, we can see that the value of this parameter is changed without server restart.
Also, before postgres 19, we could not replicate the sequence values, and now in postgresql 19, we can replicate the sequence values also.
PostgreSQL 19 brings a number of updates that make managing databases and optimizing queries easier. The built-in REPACK command helps clean up tables without needing tools. Parallel autovacuum allows multiple vacuum processes to run at the same time, which speeds up maintenance. The new autovacuum scoring system makes it smarter about which tables to clean up. Tools like pg_plan_advice and pg_stash_advice give suggestions for improving query plans. Logical replication also gets some improvements, making it more reliable and efficient. All of these changes reduce the amount of work for database administrators in large systems. Many tasks that used to need tools or manual setup can now be handled directly in PostgreSQL 19. Testing these features in an environment is a smart step. It helps administrators see how they work before using them in production. This way, they can fully use the power of PostgreSQL 19.