Read time: ~7 minutes
“Give me the last known value” is one line of English. Until PostgreSQL 19, it was two levels of window functions.
This is Part 3 of my series on what’s new in PostgreSQL 19 for application developers. Part 1 covered INSERT … ON CONFLICT DO SELECT, and Part 2 the faster SELECT expression INTO variable in PL/pgSQL.
This one is a small clause with a long history: IGNORE NULLS for window functions.
Data with gaps is everywhere:
The report always asks the same thing. For every row, show the last value we actually knew.
Let’s create a small price feed with gaps:
CREATE TABLE price_ticks (
symbol text,
tick_at timestamptz,
price numeric
);
INSERT INTO price_ticks VALUES
('DCG', '2026-11-20 09:15', 101.50),
('DCG', '2026-11-20 09:16', NULL),
('DCG', '2026-11-20 09:17', NULL),
('DCG', '2026-11-20 09:18', 102.25),
('DCG', '2026-11-20 09:19', NULL),
('DCG', '2026-11-20 09:20', 101.75);
The obvious attempt, lag() and last_value(), just hands the gaps back:
postgres=# SELECT to_char(tick_at,'HH24:MI') AS tick, price,
lag(price) OVER w AS prev_price,
last_value(price) OVER w AS last_value
FROM price_ticks
WINDOW w AS (PARTITION BY symbol ORDER BY tick_at)
ORDER BY tick_at;
tick | price | prev_price | last_value
-------+--------+------------+------------
09:15 | 101.50 | | 101.50
09:16 | | 101.50 |
09:17 | | |
09:18 | 102.25 | | 102.25
09:19 | | 102.25 |
09:20 | 101.75 | | 101.75
(6 rows)
Looks close, right? It isn’t. lag() looks exactly one row back even if that row is NULL. last_value() returns the current row’s value, NULL
I’m so pleased to announce that Bruce Momjian will be joining us in January to discuss his talk, What’s Missing in Postgres?, given at 2026.pgconf.dev. If you’re interested in joining us, please sign up using this form and I will send you an invite to one of the sessions. Sign up now: invites will be sent December 22nd.
On 24 November, PGConf Poland 2026 took place.
Organizing Committee:
Program Committee:
Speakers:
On 24 November the [Meetup PostgreSQL Lille]](https://www.meetup.com/meetup-postgresql-lille/events/317087145/) met, organized by Yoann La Cancellera.
Speakers:
On 26 November the PostgreSQL User Group NRW met, organized by Dirk Krautschick and Alexander Wirt.
Speakers:
From 26-27 November, WAWTECH took place. Devrim Gündüz and Pavlo Golub delivered a PostgreSQL talk.
Postgres Booth staffed by:
On 27 November, PostgreSQL Conference Japan 2026 happened.
Speakers:
Tutorials by:
If database connections jump after a deploy while query execution times stay flat, check whether RDS Proxy can still reuse its backends. A client normally borrows a backend for a transaction. When the proxy detects session state that must persist, it reserves that backend for the client until the client disconnects. An idle application connection can then occupy a database connection, even after COMMIT.
In CloudWatch, open Metrics → RDS → Per-Proxy Metrics. Choose the same ProxyName dimension for every series in the table and use a 60-second period. Use Sum for the counts in each minute because AWS publishes values from the underlying proxy instances. Use Average for borrow latency, which AWS reports in microseconds. Plot matching windows before and after the deployment, with comparable client traffic. AWS metric definitions and dimensions.
| Metric | Statistic | What it tells you |
|---|---|---|
DatabaseConnectionsCurrentlySessionPinned
|
Sum | Backends reserved because a client changed session state. This is a gauge, so a sustained value of 40 means roughly 40 occupied backends per sample, rather than 40 new pin events per minute. |
DatabaseConnections
|
Sum | Backend connections held by the proxy, including connections being set up. Use it as the denominator for the pinned share. |
DatabaseConnectionsCurrentlyBorrowed
|
Sum | Backends assigned to clients. Compare it with pinned and in-transaction counts on the same timeline. |
DatabaseConnectionsCurrentlyInTransaction
|
Sum | Backends in open transactions. A sus |
The Capitole du Libre is an institution within the French Free Software community. It’s one of the biggest events for free software enthusiasts, by free software enthusiasts, along with JDLL (Journée du Logiciel Libre/Day of free software) in Lyon. These are the typical places where Data Bene likes to contribute: being there, interacting with people, challenging and diffusing ideas. We were a “gold sponsor” at Capitole du Libre this year.
This status entitled us to a standing table and space for our banners. Three of us were there: Cédric, our CEO, and Catherine, our Operations and Administration Manager, who travelled halfway across France to join us, and I, the event and training manager!
I think the answer is: by not getting absorbed in all the super interesting conversations with the people who come to talk to you. I had carefully prepared my schedule with all my conferences I’m interested in, but in the end I only attended two of them. That’s also what makes this type of event for enthusiasts so appealing.
The first conference I attended was very interesting in terms of format. It was the Design Clinic, presented by Natouille and Emilie Nguyen Van Yen for Silex, a software used to easily and freely interface CSS/HTML with a CMS. The two designers shared their feedback on the homepage and the usability of the tool. They suggested improvements to readability (simplified content, a more fluid layout, etc.). They also shared design techniques that, in my opinion, should be applied everywhere:
As we're gearing up for the inaugural 1.0.0 release of pgEdge ColdFront, this is a good moment to show what it does. ColdFront transparently tiers PostgreSQL data to Apache Iceberg: your recent rows stay in Postgres, older rows move automatically to low-cost object storage in an open format, and your application keeps querying and updating all of it through the same tables, with the same SQL. It can also keep a table entirely in Iceberg from the first row, with PostgreSQL as the way in for all your reads and writes.
I presented it at two meetups in London in October, so this post has the recording of the talk, the slides, and a live demo that you can run yourself.
Keeping years of history in your primary database is expensive. The usual alternative is to move the older data out to a separate system, but then your application can no longer reach it without a pipeline in between. ColdFront gives you a better option. As data ages past a threshold you set, it moves to object storage and remains part of the database, so there is no export pipeline to build or maintain, and no application code to change.
It has two modes behind one SQL interface. Tiered mode is the one described above, with recent rows in Postgres and older rows in Iceberg. In decoupled mode, a table lives in Iceberg from the first row: every write goes straight to object storage, Postgres holds only a thin view over it, and you scale out by adding PostgreSQL nodes.
The main features:
INSERT, UPDATE and DELETE, as well as COPY and MERGE (on PostgreSQL 17 and later).
As many of you know, I’ve been doing mostly-annual blog posts about code contribution statistics for many years now, which has quite frankly been an awful lot of work. It got a lot easier a few years ago because PostgreSQL commit messages began crediting people via trailers rather than free-form text, which meant that a lot of the counting up of who did what could be automated. However, it was still pretty time-consuming.
WAIT FOR LSN in PostgreSQL 19, a 3-part series
- Part 1: Stop Fighting Synchronous Replication: Meet WAIT FOR LSN : Understand the benefits
- Part 2: Stop Fighting Synchronous Replication: Meet WAIT FOR LSN : A walkthrough for DBAs
- Part 3: WAIT FOR LSN under load: numbers, tuning and two bugs I found in PostgreSQL 19.0 (you are here)
In Part 1, I explained how WAIT FOR LSN lets the application decide when to wait for a standby, instead of making every commit wait as synchronous replication does. In Part 2, we played with it using psql.
A few psql commands can show that a feature works. They can’t show what happens with thousands of transactions per second. So I wrote a small load generator and ran several hundred thousand waits against PostgreSQL 19.0. In this final part, I will share:
That last point is also why I suggested in Part 1 to wait for PostgreSQL 19.1 before going to production.
All the numbers below come from a small Rust program I wrote for this evaluation (waitforlsn). It is a closed-loop load generator that runs one of two modes:
How it works:
Read time: ~7 minutes
In PL/pgSQL,
SELECT expr INTO vandv := exprdo the same thing. Until PostgreSQL 19, one of them was about 5x slower.
This is Part 2 of my series on what’s new in PostgreSQL 19 for application developers. Part 1 covered INSERT … ON CONFLICT DO SELECT. [part1]
This one has no new syntax at all. Your code doesn’t change. It just gets faster, if you write PL/pgSQL the way most migrated code is written.
Open any PL/pgSQL code base that came from Oracle or SQL Server. You’ll find lines like these:
SELECT clock_timestamp() INTO v_now;
SELECT v_total + v_line_amount INTO v_total;
SELECT upper(trim(p_code)) INTO v_code;
They come from habits that make sense in the source database. Oracle developers write
SELECT … INTO … FROM DUAL, and once FROM DUAL goes, SELECT … INTO stays. As the PostgreSQL 19 commit puts it, users coming from SQL Server and T-SQL “are used to writing SELECT … INTO” too.
In PL/pgSQL, every one of those lines could have been written as an assignment:
v_now := clock_timestamp();
v_total := v_total + v_line_amount;
v_code := upper(trim(p_code));
Same result. Very different cost.
Before PostgreSQL 19: Same Logic, 8x the Time
Let’s create two functions that do exactly the same work, One with assignment, one with
SELECT … INTO:
CREATE OR REPLACE FUNCTION bench_assign(n int)
RETURNS numeric LANGUAGE plpgsql AS $$
DECLARE
v numeric := 0;
i int;
BEGIN
FOR i IN 1..n LOOP
v := v + i * 2;
END LOOP;
RETURN v;
END $$;
CREATE OR REPLACE FUNCTION bench_select_into(n int)
RETURNS numeric LANGUAGE plpgsql AS $$
DECLARE
v numeric := 0;
i int;
BEGIN
FOR i IN 1..n LOOP
SELECT v + i * 2 INTO v;
END LOOP;
RETURN v;
ENDI love statistics, and I didn’t stop at the 19 release numbers: I continued looking, and this time, I’d like to talk about feature development. Or more precisely, the lack of it.
The 20 release has disturbingly few features so far. We could say that’s normal, what do I expect, it’s only 2 weeks after the 19 GA.
A regular VACUUM removed the dead rows from my test table, but its total relation size was still 70 MB. I then used PostgreSQL 19's REPACK (CONCURRENTLY), which reduced it to 14 MB.
That result was part of my earlier PostgreSQL 19 feature tests. However, it left one question: what happens to reads and writes while the table is being repacked?
I repeated the test with a larger table so the operation would run long enough to watch. Reads continued, and writes also worked during the main rewrite. At the final table swap, however, REPACK had to wait for an open read transaction to release its lock.
This is the important part: REPACK (CONCURRENTLY) reduces blocking, but it does not mean that the operation is completely lock-free.
Below is the complete test, including the commands I ran and the lock that appeared at the end.
Run this test in a test database, not on a production table.
When rows are deleted or updated, PostgreSQL leaves dead row versions behind. A regular VACUUM cleans them up and makes their space available for reuse inside the table.
However, VACUUM usually does not reduce the total space used by the table and its indexes on disk.
REPACK writes the live rows into a new table file and rebuilds the indexes. Once the rewrite is complete, PostgreSQL replaces the old table and index files with the new ones. This allows the unused space to be returned to the operating system.
| Command | Makes dead space reusable | Returns space to the operating system | Keeps the table available |
|---|---|---|---|
VACUUM
|
Yes | Usually no | Yes |
REPACK
|
Yes | Yes | No |
REPACK (CONCURRENTLY)
|
Yes | Yes | Yes, |
WAIT FOR LSN in PostgreSQL 19, a 3-part series
- Part 1: Stop Fighting Synchronous Replication: Meet WAIT FOR LSN – Understand the benefits
- Part 2: A walkthrough for DBAs (you are here)
- Part 3: WAIT FOR LSN under load: numbers, tuning and two bugs I found in PostgreSQL 19.0
In Part 1, I explained why I consider WAIT FOR LSN the most impactful feature of PostgreSQL 19, and how an application can use it instead of synchronous replication to address most of the common problems of synchronous replication. The idea is commit on the primary, take pg_current_wal_insert_lsn() on the same connection, and run WAIT FOR LSN on the standby before telling the user “done”.
Theory is fine and architects can take full advantage of this feature. However generally DBAs won’t recommend something unless they could try it themself and see things with their own eyes. The good news is that you don’t need any application to understand this feature. Two psql sessions are enough. In this part, I will show:
At the end, I will tell the long story of how this feature reached its current shape, and thank the people behind it.
Setup. All the outputs below are actual outputs captured from PostgreSQL 19.0, with a primary and one asynchronous streaming standby. In my setup the primary is on port 5433 and the standby on port 5434. If you want the same setup, the waitforlsn directory has a docker-compose.yml which creates both (PG_IMAGE=postgres:19 docker compose up -d –wait, password postgres).
$ psql -h localhost -p 5434 -U postgres -c "SELECT pg_is_in_recovery(), pg_last_wal_replay_lsn();" pg_is_in_recovery |
Also posted in Microsoft Blog for PostgreSQL
PostgreSQL 19 improves how VACUUM reads GIN indexes during cleanup, allowing that path to use streaming reads. I was curious how much of a difference that would make in practice, so I tried it out.
If an index is already in PostgreSQL’s buffer cache, there may not be much time to save by changing how pages are read. But what happens when the index is larger than the cache?
I compared PostgreSQL 18.6 and PostgreSQL 19 with GIN indexes ranging from 0.50 GiB to 26.62 GiB. The servers had 16 GiB of shared_buffers, giving me a chance to test both situations.
The small indexes finished cleanup in fractions of a second. The larger indexes were where the comparison became interesting: 1.27x median speedup at 21.30 GiB, and 2.20x at 26.62 GiB.
The size of the benefit will depend on the workload and environment.
GIN indexes are useful when one row contains many searchable items: words in a document, elements in an array, or keys and values in a jsonb value.
Unlike a simple index entry for a single scalar key, one row can contribute many GIN entries. An application can have a fairly ordinary-looking row count and still accumulate a substantial GIN index.
During cleanup, VACUUM may need to walk a large part of that index. The amount of heap cleanup and the amount of index-reading work aren’t necessarily proportional.
PostgreSQL 19’s streaming-read change makes that walk an interesting upgrade candidate. The expected benefit is easier to observe when PostgreSQL has to read index pages into its buffers, rather than finding everything there already.
That gave the experiment a specific question: does the PG18-to-PG19 difference change when the GIN index outgrows shared_buffers?
I used three independent PG18/PG19 pairs on matched Azure Database for PostgreSQL Flexible Server deployments. Each database had a dedicated runner, and the six ca
[...]In the previous article, I looked at the strengths and weaknesses of the numeric type. A significant part of the extra CPU and RAM usage you see comes from numeric values being stored in variable-length fields and requiring extra memory allocation. When this happens often, for example, with many input numbers, sorting, or lots of groups in GROUP BY, the difference becomes clear, can cause disk spilling and hurt performance.
However, real systems usually bound the size and the required precision of their operations, right? So it makes sense to implement a «fast path» for a common limited case like numeric(18,4). Here I describe several improvements that may interest the PostgreSQL community and could, perhaps, be extended to other data types.
All the optimisations below follow the same scheme. First, using the value's header and without touching the digits, we decide whether the value qualifies for the fast path. If it does, we compute the answer the short way — without allocations or full unpacking. If not, we pass the value to the existing code, which stays as it was.
Two properties follow from this. The result matches the old code bit for bit — down to the hashes used by hash indexes and partitioning machinery. The storage format does not change, and there are no new GUCs, so nothing needs to be enabled. The only price is the check at the entrance, and that check is the main source of potential regressions.
PostgreSQL operates on the Numeric structure, which has a 4-byte header and data aligned in memory. However, because its storage format is based on the varlena structure, numeric values are usually stored on disk in a co
[...]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.
WAIT FOR LSN in PostgreSQL 19, a 3-part series
If someone asks me what would be the biggest impactful feature in PostgreSQL 19, I don’t have any doubt in saying that it is WAIT FOR LSN from standby. PostgreSQL generates a new LSN (Log Sequence Number) wherever something is written to WAL. A facility to wait for LSN to reach standby is impactful because it can change the way applications are designed. It is the only feature in which I personally spend time and effort in testing and participating in hackers mailing lists with minor problems before the release of PostgreSQL 19.
A word of caution: You may start designing and developing your application around this feature. But I suggest waiting for PostgreSQL 19.1 before going for production, because a critical fix is not included in 19.0. The details, and a workaround for 19.0, are explained in Part 3 of this series.
For many years, whenever a customer wanted “the data should not be lost” or “the user must see what he just saved, even if the read goes to a replica”, the answer was mostly one: synchronous replication. And many of those customers came back to us later with a different problem: “the whole database froze”, “all commits are hanging”, “we had an outage because the standby went down”. With PostgreSQL 19, we finally have one more option. The application itself can decide when and where it wants to wait.
The content became too big for a single post, so I split it into three. In this first part, I will explain the problem, the feature, and how it can be used as a replacement for synchronous replication. Part 2 shows how DBAs can play with it using just psql, and the long history behind it. Part 3 has the numbers from my tests on the PostgreSQL 19.0 release, and the bugs I found on the w
[...]
Why should every database engineer be asking one question after the alert fires: what actually happened?
Most of the production incident ends the same way. The graphs turn green, the alert resolves, the chat channel goes quiet. Then someone asks the question that matters most:
"What actually happened?"
Most teams are very good at detecting problems. Far fewer are good at answering that question. This post is about the gap between the two, why it exists, and how we can start closing it.
Modern PostgreSQL environments generate enormous amounts of operational data: metrics, logs, statistics views, wait events, alerts. Monitoring systems are excellent at one job: telling you something needs attention.
But an alert is a starting point, not an explanation. Consider a production application that suddenly slows down. The dashboard shows higher query times, some sessions waiting, a few transactions open longer than expected. The engineer now has to reconstruct a story:
No single metric answers these. They need context, correlation and evidence.
Here is the uncomfortable part. Most of what PostgreSQL shows you about right now is gone a few minutes later.
A view like pg_stat_activity is a live picture. By the time an engineer connects, the blocking transaction may have committed, the idle session may have disconnected, and the lock wait may have cleared. The database is healthy again, and the best clues have left the building.
-- A live view. It tells you about this moment only.
SELECT pid, usename, state, wait_event_type, wait_event,
now() - xact_start AS xact_age,
left(query, 80) AS querRead time: ~8 minutes
PostgreSQL 19 finally lets
INSERThand back the row that already exists, no dummy update, no exception block, no second round trip.
PostgreSQL 19 was released on November 19, 2026. With it, I’m starting a new series: what’s new in PostgreSQL 19 primarily for application developers, the people writing SQL and PL/pgSQL every day, or supporting migrations to PostgreSQL.
Part 1 starts with the feature that removes a workaround almost every code base carries: INSERT … ON CONFLICT DO SELECT.
Every application has a get-or-create:
The ask is always the same. Give me the row — whether it was already there or not.
Until PostgreSQL 19, INSERT … ON CONFLICT couldn’t say that. DO NOTHING skips the row and returns nothing. DO UPDATE returns the row, but only by writing it again.
Let’s create a sample table:
CREATE TABLE app_users (
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
email text NOT NULL UNIQUE,
full_name text,
created_at timestamptz NOT NULL DEFAULT now()
);
INSERT INTO app_users (email, full_name)
VALUES ('deepak@dcg.com', 'Deepak Mahto');
Workaround 1: DO NOTHING, then SELECT
postgres=# INSERT INTO app_users (email, full_name)
VALUES ('deepak@dcg.com', 'Deepak M')
ON CONFLICT (email) DO NOTHING
RETURNING id, email, full_name;
id | email | full_name
----+-------+-----------
(0 rows)
INSERT 0 0
The row exists.
RETURNING gives you nothing. So the application fires a second SELECT as two round trips, and a window between them where the row can change or disappear.
The one-statement version wraps it in a CTE:
WITH ins AS (
Postgres is an extensible platform, not just a database. I’ve been cooking this year on a side project with Postgres extensions and Kubernetes – finally ready to share what I’ve built.
The CNPG Extensions Catalog is over a hundred extension images for CloudNativePG with inspectable SBOMs, rapid updates (driven by renovate with automerge when tests pass), a framework for building extensions from source when it makes sense, and a website to browse the catalog.
https://cnpg-extensions.github.io
Before we get into the controversial bits, here’s a 5-minute intro. Some history of extensions on kubernetes, licensing reasons for an independent project, a demo of catalog install and automated upgrades.
The best general collection of links I’ve seen is [the PGXN_v2 page on the Postgres wiki] – especially the blog posts, presentations and ecosystem summit.
Abigale Kim’s VLDB publication deserves a special callout: [Anarchy in the Database: A Survey and Evaluation of Database Management System Extensibility]
A few recent blogs give additional perspective:
First, it’s important to understand how the versioning works. You choose the Postgres Major Version (18 or 19) and the Debian Base Image (trixie or bookworm). You receive updates only within your Postgres and Debian version. Remember to check for locale/collation changes when switching to a different Debian base image. (And set your database default to Postgres builtin collation!)
Topic 1: Are unattended upgrades safe? Or are they too risky?
People generally agree on the importance of staying up-to-date. The offi
[...]Number of posts in the past two months
Number of posts in the past two months
Get in touch with the Planet PostgreSQL administrators at planet at postgresql.org.