Episode Transcript
[00:00:00] As I anticipated last week, there are a ton of blog posts and content about Postgres 19 given that it was released last week on November 19th. So most of the show we're going to be revisiting features that actually got into Postgres 19, but there's also a few new blog posts as well.
[00:00:20] But I hope you, your friends, family and co workers continue to do well. Our first piece of content, there was another episode of Postgres FM last week and this one they covered Postgres 19.
[00:00:32] Now I think they actually recorded this just prior to Postgres 19 officially being live. They talked about all the different reverts that happened and what actually got into Postgres 19 and then started discussing some of their favorite features. And this had both Michael, Nick and Kirk. And what's interesting with regard to the reverts, Nick was saying how he could have pushed his AI bug exploration even more to find even more bugs, but he decided to hold off a little bit to allow Postgres 19 to be released and now he's back at it again and presumably others as well using AIs to find additional bugs. And I will show this one screenshot they showed where particularly on a year time frame you can see in 2025 there were seven PostgreSQL CVEs that were resolved, whereas there have been 96 so far this year and the year hasn't even finished yet.
[00:01:31] So crazy insane amount of security patches that are having to be done which contributed to some of the reversions. But in spite of that there were a lot of features added to Postgres. First one they mentioned is repack concurrently. The next thing they mentioned was better listen notify performance and I think with a thousand notifies it was about 50 times faster in Postgres 19 compared to 18. They do have a graph or a chart that shows that in the show. They next talked about the autovacuum prioritization and as part of Nick's experiments I think he showed how it picked up a table needing vacuum 10 times faster than version 18.
[00:02:14] They of course talked about pgplannadvice and those new extensions to be able to lock plans in place or to subtly alter the plan that Postgres has by a particular query id. They mentioned some of the new defaults. So JIT is now off by default, which they praised. Also by default you get LZ4 compression for toast and I believe the wall as well if you have wall compression enabled and actually log lockweights is on too, which is great, because normally that's something I have to configure to be on. They then talked about waitfor lsn, which gives you the ability to read your writes when you're using a standby. They mentioned vacuumdb analyze only now analyzes partition parent tables, which is great. Previously you had to do that manually. They talked about pgdumper and restore now restoring statistics. They talked about logical replication sequences being transferred, although that still requires a manual step to actually refresh them.
[00:03:16] At least there's a process in place to do so. And then they also mentioned the dynamic IO worker settings that you can set, but they definitely talked a lot about each feature. If you want to listen to the episode, you can do so here or watch the YouTube video that's down here.
[00:03:32] Next piece of content PostgreSQL 19 is here worth the wait this is from pgedge.com and I would say this is a blog post that very succinctly describes some of the major features they saw in the new release of Postgres 19. Again, repack tends to be the top of people's list and repack concurrently. Of course this one also talks about the logical replication being able to refresh sequences.
[00:03:58] Talking about pgplan advice and pgstache advice. The waitfor lsn command gives you read your writes consistency on standbys. Copy from is faster on text and CSV input and copy to can now write JSON and onerror in set null lets the load continue past bad values. Got the monitoring of log lock weights and a pgstatlockview in addition to some of the defaults that they mentioned on Postgres FM max locks per transaction is changed to a new default of 128 and standard conforming strings are always on. Next blog post related this what's left in Postgres 19? This is from Percona Community and a brief discussion of what was reverted but what's in it. Again, repack concurrently is first and this one actually describes a bit more about how repack concurrently works. Insert on conflict do select so this is basically a get or create pattern and he shows it being able to ignore nulls from window functions as shown here. He talks about the wait for lsn several improvements that make query execution faster. I mentioned some of these last week, but they do have faster foreign key checks when inserting or updating rows in a reference table. Erratic sort can be used for some sorts Faster tuple deforming extracting column values from the stored row format. Actually never heard of that one and the aggregation before joins to reduce the number of rows the join has to process.
[00:05:34] Talking about the parallel autovacuum and priority based scheduling for vacuum. Analyzing tables as well as queries can now update the visibility map as opposed to having to wait for vacuum and of course pgplannadvise dash advice and then the logical replication improvements that were discussed before.
[00:05:54] And the last post I found covering PG 19 vs 18 is PostgreSQL 19 vs 18 native repack, PGPlanNadvice graph myth and Production Upgrade Guide this is from Alexey Alininoff so you can check this out if you want to see what he has to say about this Next blog post is actually talking about something I hadn't heard of but missed in Postgres 19 support multi line headers in copy from Command this is from depeche.com and he says sometimes you get a file where yes they have header information with regard to the columns if it's say a CSV file but it may have additional cruft at the top of it, maybe a title, some metadata about when it was generated, by whom the version.
[00:06:41] Well now with copy you can actually exclude these columns so that you can get a good load of the data. You don't have to pre process it. So you can see it says header line three so it skips those three columns. So that's cool. So check this out if you want to learn more. Next piece of content plan stability with PGStash advice how to do it in practice this is from cyber.kyvanpostgresql.com and I always like Lorenz's posts and here he runs through the process of setting up PGPlan advice and PG Stash advice. So he has an example of doing a multi join query and when you have a producer named Acme it can actually cause a much slower query based upon the layout of the data runs in about a half a second because of its join plan and he goes through the process of adjusting that plan with pgplannadvice and locking it in place with pgstash advice so when this query is seen it could use the optimize plan.
[00:07:40] Now he does have a section here. Is pgstach advice the best way to tune this query? And he says probably not. And the thing to keep in mind is that if your statistics are up to date and you don't have too much data skew and you have reasonably indexes, you probably shouldn't need to reach for this too much at all. But if you have problems with data skew and maybe your workload doesn't allow fully optimized indexes. This could be a way to keep the execution of these queries relatively stable. In this example, all he had to do was set random page cost to 1.1 and Postgres picks a good plan for the process query. So there are advantages to locking a plan in place. But then again as your data changes as a new index gets introduced, that could actually lock you into a worse performing plan as opposed to letting the planner pick the optimum plan at that particular point in time. And I like this comment here.
[00:08:40] I advise to use a light hand when using pgstach advice and in this particular example he didn't force the join method or how tables should be scanned and then he showed another example where you could split these into two queries to make them faster.
[00:08:56] But if you do plan on using the pgplannadvice pgstash advice extension, definitely advise you to check out this blog post. Another one related to it PostgreSQL19 when the planner needs adult supervision this is from drunkdba.medium.com he covers these extensions as well, so you can check it out here and and the next piece of content the numbers of PostgreSQL this is from percona.community and he's talking about the development numbers in terms of commits, submissions, line changes across different versions. And a lot of these are linear in nature, they don't vary too much, but it was a pretty significant jump. The number of commits in this Release compared to Postgres 19 seems like almost a third more, almost at least a quarter more. But look at the number of lines changed per release. We've essentially doubled the number of line changes in Postgres 19. Of course with AI that's easy to do. I don't know how much committers have actually used AI in writing the code, but it still indicates a large amount of changes in this release.
[00:10:07] Then they talk about the number of commits per month from the feature freeze. You can see with 18 how after feature freeze the number of commits definitely trailed off down to 61, whereas after 19 after the feature freeze those commits stayed at 200 persistently up until pretty much it looks like the release date still at 200, so three times the volume before the release, so definitely showing AI having an impact.
[00:10:36] And look at the number of commits that were also backported to older branches. Normally that seems to be a little over 500 or less in all the past releases to Postgres 11, whereas Postgres 19 had over 1000, so essentially double the number of commits were backported to previous versions. So a lot of work had to be done. And he talks about the mailing list and how active that was, which I covered in a blog post by depash a week or two ago on scaling Postgres.
[00:11:05] So it's definitely showing the level of work that has had to be done with Postgres 19 compared to previous releases. And check this out if you want to learn more. Next piece of content squeezing tables with Postgres 19 this is from enterprisedb.com and this actually tells the story of how PGrepack and its concurrently option got into Postgres. So if you want to walk through that story, definitely found this interesting.
[00:11:32] Next piece of content actually something not 19 related, but how to deal with slow shutdown in PostgreSQL this is from cyber.postgresql.com now the trick I always use to speed up shutting down is send the system a commit and once that's complete do another commit and then actually do the shutdown or the restart. But he first starts off saying hey, before you consider that, make sure you're using the right shutdown modes with Postgres.
[00:12:02] So a smart shutdown doesn't allow any new connections, waits for the last client to disconnect, and then shuts down cleanly. The fast shutdown actually terminates all existing connections and shuts down cleanly.
[00:12:15] The last one is an immediate shutdown. It kills all processes and exits without a clean shutdown. So you would want to avoid this if you can, because then on the next restart it has to do a full recovery.
[00:12:29] This is probably the best way to get a fast restart if you need one. Or this if you can take your time, wait for connections to finish. But he covers how to speed up a restart or a shutdown and he gives the advice I just mentioned you do a checkpoint beforehand and then do a restart. Although I tend to like to do two checkpoints, but it kind of depends on how active your system is. But he does mention something that should be taken into account, and that is if you have unlogged tables, because that can cause a slow shutdown as well because unlocked tables are not logged to the wall. What happens when a restart happens is it needs to flush this data to disk, so that can take some time.
[00:13:12] Now how you avoid it? Well, if you're on Postgres 19, so I guess this is semi related 19 you can do a checkpoint but add flush unlog so it will flush those unlogged tables to the disk so that you can then do a clean restart without having to have them be written again.
[00:13:32] The other way, based upon when unlogged tables get flushed, is to actually create a dummy database, go ahead and copy it from template zero and use strategy file copy, which you can do in version 15 and later. So that just makes it faster, which since 14 is end of life, you should probably be using that by now. And then just drop that dummy database that actually writes those unlogged tables to the disk and then you can do your restart. And he did a test to actually demonstrate that here. So he did a createdb command strategy file copy, called it dummy, then he dropped the dummy and then he did a stop. Okay, so it looks like this create and drop DB also triggers a checkpoint. So I guess you don't have to do checkpoint as well. So that's great. But if you want to learn more, check out this blog post. Next piece of content pgai, Bench and AAA Can AI safely change production Postgres? This is from Postgres AI and I thought this is an interesting blog post because Nick definitely wants to get AIs to be able to manage post Postgres systems. And the question is how to do that safely. Can we trust them to carry out work? Can we not trust them? And he did some research into this and had four key learnings.
[00:14:53] Number one, high capability, which means the most advanced models at this point in time, Fable 5.2 Opus 5.5 High Capability does not prevent live outages.
[00:15:05] So in his experiments they would do things that would basically cause outages. Like he says, acting alone clawed Fable 5.2, tied for the top score, yet still broke an explicit no restart rule in all five of five repeats on a task. So basically we can't trust them, much like humans, I suppose. The second learning, a deterministic clone gate, stops mechanical failures at 0llm cost.
[00:15:33] Yet blind spots remain. So we'll talk about this deterministic, which that's definitely appealing to me.
[00:15:40] The next learning green clone summaries can both reassure and mislead AI reviewers. So basically they're doing clones to experiment a particular change to see what impact it will have. And apparently if that clone is good and green, it can still lead to confusion, apparently amongst the AIs. But the last one is the good news. Separating duties can cut live harm sharply.
[00:16:04] So what he's proposing is a division of labor that I think he said came from a Google site, Reliability engineer change management book, and that you should consider having Three roles. One is an analyst which investigates the issues and drafts a resolution.
[00:16:23] It holds zero production write access, so it does not access to the production database.
[00:16:29] So basically it assesses what should be done. Then you have an actor, basically that which executes, and that is a deterministic engine that actually has access to the database. So it rehearses on clones and then it gives those results off to an auditor role. And the auditor role is another AI that inspects what needs to be done against the clone or the results of the tests that have been done before giving approval to go ahead and do the work. So the separation was apparently much safer in his experiments.
[00:17:05] So I found this interesting. I still think we have the issue of the AI reading errant instructions in databases, so I'm still really cautious about that. But if you want to learn more about this, definitely check out this blog post and the last piece of content. Why you shouldn't do application level sharding this is from planetscale.com and he's talking about a scenario where your database is growing rather quickly and your level of writes are exceeding what the largest server instance you can use is capable of. Well, you could choose to shard in your application and the way that they're describing sharding here is basically just sharding your data, basically by doing a modulo so you split by a user ID into multiple shards. So you're still sharding the data itself.
[00:17:57] This is one way to do sharding and splitting up. So I definitely agree. I wouldn't do this type of application sharding because this feels like a database level concern on how you're splitting the data. And I would use one of the existing database tools to do that. That could be PlanetScale's NEKI, that could be PGDOG with their scale out pooler, that could be multigres when it's available. Or it could just be Citus, which we've covered all of these previous episodes of scaling Postgres.
[00:18:30] Where application sharding may still work is if you have workflow based sharding. So if you have a part of your application you move off to this particular database system like tracking events is handled in entirely separate database and those are the only tables that track events and you combine that data with your other database. So you're sharding along workflow or responsibility areas as opposed to just sharding the data. If you're just sharding the data like this, I would definitely use one of the solutions I mentioned, but they go over the issues you can run into, not necessarily on day one, but day two, three, etc. In dealing with trying to do the sharding yourself in the application. But if you want to learn more, definitely check this out. I hope you enjoyed this episode. Be sure to check out scalingpostgres.com where you can find links to all the content discussed, as well as sign up to receive weekly notifications of each episode. There you can find an audio version of the show as well as a full transcript. Thanks. I'll see you next week.