Dimitri Fontaine: What Changes for SQL in PostgreSQL 19
2026年12月1日
AI 摘要 AI 生成,可能有误
本文通过在 19.0 和 18.6 版本上运行《The Art of PostgreSQL》一书中的查询,并阅读最终的发布说明,分析了 11 月 19 日发布的 PostgreSQL 19.0 对 SQL 带来了哪些变化。调查发现包括:7 项在发布前被撤回的重点特性、11 项影响现有 SQL 的变更、大约 20 项新功能,以及一份包含 8 个步骤的升级检查清单。尽管发布当日的文章着重介绍了 REPACK、计划建议和 ON CONFLICT DO SELECT,但对现有 SQL 影响最大的变化是:规划器现在会读取 NOT NULL 约束并据此重写查询。
Postgres 19.0 was released on November 19. Two articles covered the beta
here in September, Getting Ready for PostgreSQL
19 and Plan Advice in
PostgreSQL 19. Before updating
The Art of PostgreSQL for 19, we ran the queries it teaches on 19.0 and on
18.6, and read the final release notes against them. This article is what
we found, limited to what Postgres 19 changes: 7 headline features
withdrawn before the release, 11 changes that reach SQL you already wrote,
about 20 new features, and an 8-step checklist for the upgrade.
The release-day posts mostly lead with REPACK, plan advice and ON CONFLICT DO SELECT. For SQL that already exists, the change with the most
consequences is quieter: the planner now reads your NOT NULL constraints
and rewrites queries with them.
▸
继续阅读全文
为了尊重作者,这里只展示开头几段。你可以去原文阅读,或者在 HorizonReader 里读:划线做笔记、让 AI 帮忙。
AI 摘要On December 23, 2025, Masahiko Sawada committed a patch to PostgreSQL that allows logical decoding to be toggled dynamically based on the presence of logical replication slots. Previously, logical decoding required wal_level to be set to 'logical' at server start, meaning users had to bear the overhead of logical-level WAL logging even when no logical replication slots were in use. Despite this improvement, the feature was missed in PostgreSQL 19.
AI 摘要This article is Part 2 of a series on PostgreSQL 19's WAIT FOR LSN feature, offering DBAs a hands-on walkthrough using just two psql sessions to demonstrate read-your-writes consistency on replicas, timeout handling with NO_THROW, monitoring waiting sessions, and how WAIT FOR behaves when a standby is stuck compared to synchronous replication. It also explains the feature's errors and restrictions—such as being unusable while holding snapshots or locks and only allowed as a top-level statement—showing why each exists to prevent deadlock cycles with recovery. Finally, it recounts the feature's long development history, including multiple commits and rejections over more than six years.
AI 摘要This blog post by Christophe Pettus discusses the PostgreSQL parameter session_preload_libraries, reaffirming the earlier advice to use it instead of local_preload_libraries. The author notes that despite the parameter's simple job of calling dlopen(), there is more fine print to explain than expected, starting with the fact that its default value is empty.
AI 摘要A regulated payments company successfully migrated over 40 TB of production data to a new EDB Postgres cluster with a single-night cutover, made possible by months of preparation using a replication-based approach. Key lessons included sizing the timeline around the largest tables (8.6 TB and 4.5 TB), using parallel workers to speed up backfill, monitoring WAL growth on the source, and building regulatory notice periods into the schedule. The team also stresses post-cutover 'hypercare' monitoring for a week, which caught a standby replication lag early and prevented potential production issues.
AI 摘要This article, the first in a three-part series, introduces PostgreSQL 19's WAIT FOR LSN feature, which allows applications to wait until a given WAL position has reached a standby, offering a flexible alternative to synchronous replication. It explains the drawbacks of synchronous replication—such as all commits hanging indefinitely when a standby fails, with statement_timeout providing no help—and demonstrates how combining WAIT FOR LSN (with modes like standby_replay and standby_flush) with synchronous_commit = off gives per-transaction durability and read-your-writes guarantees. The author also covers important caveats, including timeout handling, connection pool sizing on the standby, and critical tuning of wal_writer_flush_after and wal_writer_delay, while cautioning readers to wait for PostgreSQL 19.1 before production use due to a bug in 19.0.