PostgreSQL 19 Released

本文为原文前 6,000 字符的节选翻译,完整内容请查看原文。

PostgreSQL 19 Released

November 19, 2026: PostgreSQL 19 Released! Quick Links About Governance Policies Feature Matrix Donate History Sponsors Contributing Financial Servers Latest News Upcoming Events Past events Press Licence PostgreSQL 19 Released! Posted on 2026-11-19 by PostgreSQL Global Development Group PostgreSQL Project November 19, 2026 - The PostgreSQL Global Development Group today announced the release of PostgreSQL 19, the latest version of the world’s most advanced open source database.

2026年11月19日:PostgreSQL 19 发布!快速链接 关于 治理 政策 功能矩阵 捐赠 历史 赞助商 贡献 财务 服务器 最新新闻 即将举行的活动 往届活动 新闻 许可 PostgreSQL 19 发布!由 PostgreSQL 全球开发组于 2026 年 11 月 19 日发布。PostgreSQL 项目 2026 年 11 月 19 日 - PostgreSQL 全球开发组今日宣布发布 PostgreSQL 19,这是全球最先进的开源数据库的最新版本。

Mission-critical usage of PostgreSQL continues to rapidly rise, and PostgreSQL 19 responds to this by simplifying both administration and development for these workloads at scale. This release introduces the REPACK (CONCURRENTLY) command so users can optimize tables for their current workload without disruption to ongoing operations. PostgreSQL 19 gives users better control over plan stability and query performance with the new pg_plan_advice extension.

PostgreSQL 在关键任务中的使用率持续快速增长,PostgreSQL 19 通过简化这些大规模工作负载的管理和开发来应对这一需求。此版本引入了 REPACK (CONCURRENTLY) 命令,以便用户可以在不中断当前操作的情况下优化表以适应当前的工作负载。PostgreSQL 19 通过新的 pg_plan_advice 扩展,让用户能够更好地控制计划稳定性和查询性能。

Developers will find many delightful features in this release, from support for “read-your-writes” consistency on standbys to “get or create” behavior that saves a network round trip. “For over 30 years, the global open source community has built PostgreSQL into a database that organizations trust with their most critical data,” said Jonathan Katz, a member of the PostgreSQL core team. “PostgreSQL 19 continues that commitment to reliability, giving users new ways to manage their workloads without disruption and to build applications that span multiple systems.”

开发人员将在本次发布中发现许多令人欣喜的功能,从对备库“读写一致性”的支持,到节省网络往返次数的“获取或创建”行为。PostgreSQL 核心团队成员 Jonathan Katz 表示:“30 多年来,全球开源社区将 PostgreSQL 打造成了一个组织可以信赖其最关键数据的数据库。PostgreSQL 19 延续了对可靠性的承诺,为用户提供了在不中断的情况下管理工作负载以及构建跨多个系统应用程序的新方法。”

PostgreSQL, an innovative data management system known for its reliability, robustness, and extensibility, benefits from 30 years of open source development from a global developer community and has become the preferred open source relational database for organizations of all sizes. Simplifying workload management Tables that receive many updates and deletes can build up unused space, known as “bloat,” which can also significantly impact query performance.

PostgreSQL 是一种以可靠性、稳健性和可扩展性著称的创新数据管理系统,得益于全球开发人员社区 30 年的开源开发,它已成为各种规模组织首选的开源关系数据库。简化工作负载管理:接收大量更新和删除操作的表会积累未使用的空间,即“膨胀”,这也会显著影响查询性能。

The VACUUM FULL and CLUSTER commands were previously used to handle this, but had tradeoffs, including preventing access to the table until the cleanup finished. PostgreSQL 19 introduces the REPACK command, which reclaims this space and can reorder a table’s data to match an index, and with REPACK (CONCURRENTLY), can do so without blocking reads or writes. REPACK replaces the VACUUM FULL and CLUSTER commands, both of which remain available for compatibility.

此前,VACUUM FULL 和 CLUSTER 命令被用于处理此问题,但存在权衡,包括在清理完成前阻止对表的访问。PostgreSQL 19 引入了 REPACK 命令,该命令可以回收此空间并重新排列表数据以匹配索引,并且通过 REPACK (CONCURRENTLY),可以在不阻塞读写的情况下完成此操作。REPACK 取代了 VACUUM FULL 和 CLUSTER 命令,但为了兼容性,这两个命令仍然可用。

The PostgreSQL query planner usually picks an efficient plan for each query, but the plan can change as your data changes, and sometimes the new plan is slower. PostgreSQL 19 adds the pg_plan_advice extension, which allows stabilization of plan choices and the ability to experiment with different plans using the “plan advice” mini-language. The companion pg_stash_advice extension stores advice and automatically applies it to queries based on their query identifier, so you can fix a slow plan without changing your application.

PostgreSQL 查询规划器通常会为每个查询选择一个高效的计划,但随着数据的变化,计划可能会发生改变,有时新计划会更慢。PostgreSQL 19 添加了 pg_plan_advice 扩展,它允许稳定计划选择,并能够使用“计划建议”微语言来试验不同的计划。配套的 pg_stash_advice 扩展可以存储建议,并根据查询标识符自动将其应用于查询,因此您无需更改应用程序即可修复缓慢的计划。

PostgreSQL 19 also helps autovacuum keep up on busy systems. Autovacuum can now vacuum indexes using parallel workers, controlled by the new autovacuum_max_parallel_workers setting, and uses a new scoring system to decide which tables to process first. Queries that read a table can now automatically mark pages as all-visible in the visibility map during execution, reducing the work that future vacuums need to do. Additionally, vacuumdb —analyze-only now analyzes partitioned tables when no tables are specified.

PostgreSQL 19 还帮助自动清理(autovacuum)在繁忙的系统上保持同步。自动清理现在可以使用并行工作进程来清理索引,这由新的 autovacuum_max_parallel_workers 设置控制,并使用新的评分系统来决定优先处理哪些表。读取表的查询现在可以在执行期间自动在可见性映射中将页面标记为“全部可见”,从而减少未来清理工作需要做的工作。此外,当未指定表时,vacuumdb —analyze-only 现在会分析分区表。

This release adds new views for monitoring workloads, including pg_stat_lock for per-lock-type statistics, pg_stat_recovery for recovery status, and pg_stat_autovacuum_scores to show how autovacuum prioritizes tables. The new IO option for EXPLAIN ANALYZE and the matching auto_explain setting report asynchronous I/O activity. PostgreSQL 19 also reports the amount of WAL written for full-page images in pg_stat_wal, EXPLAIN (ANALYZE, WAL), and in vacuum and analyze log events.

此版本增加了用于监控工作负载的新视图,包括用于按锁类型统计的 pg_stat_lock、用于恢复状态的 pg_stat_recovery,以及用于显示自动清理如何优先处理表的 pg_stat_autovacuum_scores。EXPLAIN ANALYZE 的新 IO 选项和匹配的 auto_explain 设置可以报告异步 I/O 活动。PostgreSQL 19 还在 pg_stat_wal、EXPLAIN (ANALYZE, WAL) 以及清理和分析日志事件中报告为全页图像写入的 WAL 量。

Distributed data improvements Previously, PostgreSQL often required users to restart their server to enable logical replication, which could be disruptive in production workloads. PostgreSQL 19 simplifies logical replication initialization by automatically raising the effective WAL level to logical when you create the first logical replication slot. You can see the WAL level in use with the new effective_wal_level setting.

分布式数据改进:此前,PostgreSQL 通常要求用户重启服务器以启用逻辑复制,这在生产工作负载中可能会造成干扰。PostgreSQL 19 通过在创建第一个逻辑复制槽时自动将有效的 WAL 级别提升为逻辑级别,简化了逻辑复制的初始化。您可以使用新的 effective_wal_level 设置查看正在使用的 WAL 级别。

PostgreSQL 19 also adds logical replication of sequence values, which you can publish using FOR ALL SEQUENCES with CREATE PUBLICATION. CREATE PUBLICATION also adds an EXCEPT clause to exclude tables when publishing FOR ALL TABLES, and CREATE SUBSCRIPTION can now get its connection settings from a foreign server, such as one defined with postgres_fdw, using the SERVER clause. Additionally, the new retain_dead_tuples subscription option lets PostgreSQL detect updates that conflict with a concurrent delete, and these conflicts are counted in pg_stat_subscription_stats.

PostgreSQL 19 还增加了序列值的逻辑复制,您可以使用 CREATE PUBLICATION 中的 FOR ALL SEQUENCES 来发布这些值。CREATE PUBLICATION 还添加了一个 EXCEPT 子句,以便在发布 FOR ALL TABLES 时排除表;CREATE SUBSCRIPTION 现在可以使用 SERVER 子句从外部服务器(例如使用 postgres_fdw 定义的服务器)获取其连接设置。此外,新的 retain_dead_tuples 订阅选项允许 PostgreSQL 检测与并发删除冲突的更新,这些冲突会在 pg_stat_subscription_stats 中进行统计。

For applications that send reads to standbys, PostgreSQL 19 adds “read-your-writes” consistency with the new WAIT FOR LSN command. A session on a standby can use WAIT FOR LSN to wait until the standby has replayed the write-ahead log (WAL) up to a specific log sequence number (LSN) before running a query, so the application can read data it just wrote on the primary. PostgreSQL 19 also improves queries on foreign tables. With the new import_stats option, postgres_fdw can import table statistics from the remote server when you run ANALYZE, instead of sampling rows from the remote table, which helps the query planner choose better plans.

对于将读取操作发送到备库的应用程序,PostgreSQL 19 通过新的 WAIT FOR LSN 命令增加了“读写一致性”。备库上的会话可以使用 WAIT FOR LSN 等待备库重放预写日志 (WAL) 直到特定的日志序列号 (LSN),然后再运行查询,这样应用程序就可以读取它刚刚在主库上写入的数据。PostgreSQL 19 还改进了对外部表的查询。通过新的 import_stats 选项,postgres_fdw 可以在您运行 ANALYZE 时从远程服务器导入表统计信息,而不是从远程表中采样行,这有助于查询规划器选择更好的计划。

Developer experience and performance enhancements PostgreSQL 19 adds INSERT … ON CONFLICT DO SELECT, which lets the RETURNING clause return existing rows that conflict with an insert, simplifying the common “get or create” pattern. COPY can now output data as JSON, including as a single JSON array, and the SQL/JSON path language adds string methods such as lower(), upper(), replace(), spl

开发人员体验和性能增强:PostgreSQL 19 添加了 INSERT … ON CONFLICT DO SELECT,它允许 RETURNING 子句返回与插入冲突的现有行,从而简化了常见的“获取或创建”模式。COPY 现在可以将数据输出为 JSON,包括作为单个 JSON 数组,并且 SQL/JSON 路径语言添加了诸如 lower()、upper()、replace()、spl 等字符串方法。