PostgreSQL 19 chính thức ra mắt: dọn bloat không cần khóa bảng với REPACK, ghim plan truy vấn bằng pg_plan_advicePostgreSQL 19 released: clear bloat without locking tables with REPACK, pin query plans with pg_plan_advice

PostgreSQL 19 phát hành ngày 19/11/2026: REPACK (CONCURRENTLY) dọn bloat mà không khóa bảng, pg_plan_advice ghim query plan đang chạy tốt, replication không cần restart — bản major đặt vận hành và nâng cấp không gián đoạn làm trọng tâm, miễn phí theo PostgreSQL License.PostgreSQL 19, released on November 19, 2026, brings REPACK (CONCURRENTLY) to clear table bloat without locks, pg_plan_advice to pin query plans that already perform well, and logical replication without a restart — a major release focused on operations and upgrades without downtime, free under the PostgreSQL License.
Lần đầu tiên, bạn có thể dọn sạch "bloat" của một bảng PostgreSQL mà không cần khóa bảng — và lần đầu tiên có cách chính thức để ghim một query plan đang chạy tốt, không cho planner tự ý đổi sang plan chậm hơn. PostgreSQL 19, phát hành ngày 19/11/2026, là bản major tập trung vào một thông điệp duy nhất: vận hành và nâng cấp không gián đoạn.
Thay đổi gì
| Tính năng | Tóm tắt | Ai hưởng lợi nhất |
|---|---|---|
REPACK (CONCURRENTLY) | Thu hồi dung lượng thừa và sắp xếp lại dữ liệu bảng mà không khóa đọc/ghi; thay thế VACUUM FULL và CLUSTER | Đội vận hành DB lớn, bảng phình to vì update/delete nhiều |
pg_plan_advice + pg_stash_advice | Ổn định lựa chọn plan của planner, thử nghiệm plan bằng mini-language, tự áp dụng theo query ID mà không sửa app | Ai từng bị plan truy vấn "đổi ý" bất chợt làm chậm hệ thống |
INSERT ... ON CONFLICT DO SELECT | RETURNING trả về luôn row đã tồn tại khi insert bị trùng — mẫu "get or create" không còn tốn thêm một round trip | Developer viết API, worker idempotent |
WAIT FOR LSN | Session trên standby chờ tới khi replay WAL tới đúng LSN rồi mới query — đọc được dữ liệu vừa ghi trên primary ("read-your-writes") | App đọc từ replica |
| Logical replication không cần restart | Tạo slot replication đầu tiên tự nâng WAL level lên logical; thêm replication sequence (FOR ALL SEQUENCES), EXCEPT khi publish FOR ALL TABLES | Đội dùng CDC / replication |
| Hiệu năng | Kiểm tra foreign key nhanh hơn — bulk insert nhanh gần 2x trong thử nghiệm; NOT IN chuyển thành anti-join; eager aggregation trước join | Mọi workload ghi nặng |
| Autovacuum song song | Vacuum index bằng parallel workers (autovacuum_max_parallel_workers), hệ thống chấm điểm ưu tiên bảng cần xử lý trước | Hệ thống bận rộn, bảng lớn |
Vì sao dev cần quan tâm
Trọng tâm của bản 19 không phải tốc độ thô mà là quyền kiểm soát: kiểm soát bloat mà không downtime, kiểm soát plan mà không sửa code, kiểm soát replication mà không restart server. Đội vận hành DB lớn hưởng lợi trực tiếp từ REPACK; ai từng bị plan truy vấn "đổi ý" bất chợt làm chậm hệ thống nay có công cụ chính thức để ghim plan; developer viết API và worker idempotent tiết kiệm được một round trip với mẫu "get or create" mới; app đọc từ replica có được đảm bảo read-your-writes qua WAIT FOR LSN.
Một lưu ý thực tế: lịch phát hành đã lùi từ cuối tháng 9/đầu tháng 10 sang 19/11, và 8–10 tính năng đã bị revert trước GA để đảm bảo ổn định — nên bản 19 này thiên về chắc chắn hơn là tham vọng.
Chi tiết cách hoạt động
Với REPACK (CONCURRENTLY), cần một replication slot dự phòng, bảng phải có replica identity (primary key không deferrable hoặc unique index phù hợp), đủ dung lượng trống cho một bản copy của bảng và index; theo Databricks, thao tác có thể thất bại nếu có khoảng 104 triệu row bị update/delete trong lúc chạy, và không an toàn với transaction giữ snapshot từ trước khi repack.
PostgreSQL 18 (2025) mang tới hệ thống I/O bất đồng bộ; PostgreSQL 19 xây tiếp trên nền đó — I/O worker nay tự điều chỉnh số lượng trong khoảng io_min_workers – io_max_workers.
Một số thay đổi mặc định cần biết: JIT tắt mặc định (ước tính chi phí trước đây không đáng tin — query phân tích lớn nên bật lại tay), nén TOAST mặc định chuyển sang LZ4 (khi build có LZ4), xác thực RADIUS bị gỡ bỏ, và đăng nhập bằng mật khẩu md5 nay hiện cảnh báo sau mỗi lần đăng nhập thành công — md5 đã deprecated từ PG 18 và sẽ bị xóa trong bản tương lai, hãy dùng SCRAM. Ngoài ra còn có hỗ trợ SNI phía server, COPY ... (FORMAT json), các hàm chuỗi mới cho SQL/JSON path (lower(), upper(), replace(), split_part(), btrim()), window function hỗ trợ IGNORE NULLS, và random() sinh được ngày/giờ ngẫu nhiên trong khoảng.
Giá và thời điểm dùng được
PostgreSQL 19 miễn phí, mã nguồn mở theo PostgreSQL License. Tải ngay từ trang download chính thức của postgresql.org (Windows, Linux, macOS, source code). Databricks đã đưa PG 19 lên dịch vụ Lakebase ngay trong ngày phát hành; EDB bắt đầu hỗ trợ từ 19/11. Lưu ý: bản 19.1 dự kiến tháng 02/2027 — nhiều đội vẫn chờ bản .1 mới đưa lên production, như thông lệ.
✅ Việc cần làm
Nếu bạn chạy PostgreSQL:
- Thử trên staging trước: nâng một bản sao lên PG 19, chạy
REPACK (CONCURRENTLY)trên bảng bloat nhất và đo thời gian + tác động. - Kiểm tra extension: xác nhận các extension bạn dùng đã có bản build cho PG 19 (một số extension trên Lakebase vẫn đang chờ nhà cung cấp).
- Production đang chạy ổn định: có thể chờ 19.1 (tháng 02/2027) theo thông lệ, nhưng lên kế hoạch thử nghiệm từ bây giờ.
- Đang đau đầu vì plan truy vấn thay đổi thất thường: thử
pg_plan_adviceđể ghim plan đang chạy tốt.
For the first time, you can clear a PostgreSQL table's "bloat" without locking the table — and for the first time there is an official way to pin a query plan that already performs well, stopping the planner from switching to a slower one on its own. PostgreSQL 19, released on November 19, 2026, is a major release built around a single message: operations and upgrades without interruption.
What changed
| Feature | Summary | Who benefits most |
|---|---|---|
REPACK (CONCURRENTLY) | Reclaims wasted space and reorganises table data without locking reads/writes; replaces VACUUM FULL and CLUSTER | Operators of large databases, tables bloated by heavy updates/deletes |
pg_plan_advice + pg_stash_advice | Stabilises the planner's plan choices, experiments with plans via a mini-language, applies automatically by query ID without changing the app | Anyone whose query plan suddenly "changed its mind" and slowed the system |
INSERT ... ON CONFLICT DO SELECT | RETURNING returns the already-existing row when an insert conflicts — the "get or create" pattern no longer costs an extra round trip | API developers, idempotent workers |
WAIT FOR LSN | A session on a standby waits until WAL replay reaches an exact LSN before querying — reading data just written on the primary ("read-your-writes") | Apps reading from replicas |
| Logical replication without restart | Creating the first replication slot automatically raises the WAL level to logical; adds replication sequences (FOR ALL SEQUENCES) and EXCEPT when publishing FOR ALL TABLES | Teams using CDC / replication |
| Performance | Faster foreign-key checks — bulk inserts nearly 2x faster in testing; NOT IN becomes an anti-join; eager aggregation before joins | Every write-heavy workload |
| Parallel autovacuum | Index vacuuming with parallel workers (autovacuum_max_parallel_workers), with a scoring system that prioritises the tables most in need | Busy systems, large tables |
Why developers should care
The focus of version 19 is not raw speed but control: control bloat without downtime, control plans without changing code, control replication without restarting the server. Operators of large databases benefit directly from REPACK; anyone whose query plan suddenly changed and slowed the system now has an official tool to pin the plan; API developers and idempotent workers save a round trip with the new "get or create" pattern; apps reading from replicas get a read-your-writes guarantee through WAIT FOR LSN.
One practical note: the release slipped from late September / early October to November 19, and 8–10 features were reverted before GA to protect stability — so this 19 release leans towards solidity over ambition.
How it works
REPACK (CONCURRENTLY) needs a spare replication slot, the table must have a replica identity (a non-deferrable primary key or a suitable unique index), and there must be enough free space for a copy of the table and its indexes; according to Databricks, the operation can fail if roughly 104 million rows are updated or deleted while it runs, and it is not safe with transactions holding a snapshot from before the repack.
PostgreSQL 18 (2025) brought the asynchronous I/O system; PostgreSQL 19 builds on that foundation — I/O workers now adjust their own count within the io_min_workers – io_max_workers range.
Some default changes to know: JIT is off by default (the earlier cost estimates proved unreliable — large analytical queries should re-enable it manually), TOAST compression defaults to LZ4 (when built with LZ4), RADIUS authentication is removed, and md5 password logins now show a warning after every successful login — md5 has been deprecated since PG 18 and will be removed in a future release, so use SCRAM. There is also server-side SNI support, COPY ... (FORMAT json), new string functions for SQL/JSON paths (lower(), upper(), replace(), split_part(), btrim()), window functions supporting IGNORE NULLS, and random() able to generate random dates/times within a range.
Price and availability
PostgreSQL 19 is free, open source under the PostgreSQL License. Download it now from the official postgresql.org download page (Windows, Linux, macOS, source code). Databricks put PG 19 on its Lakebase service on release day; EDB support began on November 19. Note: 19.1 is expected in February 2027 — many teams still wait for the .1 release before going to production, as usual.
✅ What to do
If you run PostgreSQL:
- Try it on staging first: upgrade a copy to PG 19, run
REPACK (CONCURRENTLY)on your most bloated table and measure the time and impact. - Check extensions: confirm the extensions you use already have PG 19 builds (some extensions on Lakebase are still waiting on their vendors).
- Production running stably: you can wait for 19.1 (February 2027) as usual, but start planning the trial now.
- Struggling with query plans that keep changing: try
pg_plan_adviceto pin the plan that already performs well.
Nguồn tham chiếuSource: PostgreSQL Global Development Group


