Scaling Postgres · Creston Jamison
In this episode of Scaling Postgres, we discuss the reasons for all the PG 19 reversions, why open source wins, the cost of REPACK CONCURRENTLY and hint implementations. To get the show notes as well as get notified of new episodes, visit: https://www.scalingpostgres.com/episodes/437-reason-for-reversions/ Want to learn more about Postgres performance? Join my FREE training called Postgres Performance Demystified here: https://www.scalingpostgres.com/courses/postgres-performance-demystified/
0:00Part of me wishes that Postgres 19 was released already so we wouldn't have all these blog posts and discussions about why Postgres 19 is late and is AI to blame or not to blame. But unfortunately I found the most interesting post talking about the state of 19 and actually focusing on some features that are coming as well. But hopefully in a couple of weeks the show starts will be a little different.
0:27But I hope you, your friends, family and coworkers continue to do well. Our first piece of content Are we reverting patches because of bugs found by AI? This is from Vondra Me and the first thing he mentions is that, you know, there was this blog post by Elizabeth Christensen that was saying basically AI is helping find bugs that's causing these features to get reverted. Although he presents some data that shows, of course, a more nuanced view than that. So he talks about the different patches reverted from Postgres 19 and he talks about the reasons why they were reverted, as well as a conclusion on whether it was AI or not. And he goes through a lot of detail with regard to each one. A lot of them are not AI, although I'm sure AI still probably had some role in the work given the state of things nowadays.
1:22And ultimately I don't think it matters whether AI was the reason or not necessarily, but I think he represents a pretty good interpretation of what happened. So we did look at reverts in the past. So we looked at PG14 through PG19 releases and when things tended to be reverted. So this is a revert count on the left here. Now what you can see is the slope of the PG19 quite sharp. So there were, it looks like up to 10 reverts that happened in a matter of 10 to 15 days.
1:56There are some sharp slopes in some other releases, but they were earlier. So the significance of this is that it is a pretty steep slope and how late it happened. So basically people had already assumed features would probably get in at this time.
2:12And in this early phase, when other releases had sharp increases in the number of reverts, pg 19 was relatively stable during this time. And they said day 275, which is around here, is when the feature freeze happens for each of the versions. So not much happened after feature freeze. And then he looks at this other chart of the cumulative revert changes with regard to insertions and deletions, and you can see PG19 is definitely off the chart.
2:41So my interpretation is this is lines of code. So at least the magnitude of PG 19 has been significant. It seems more than twice as much as any previous release, as well as a lot of the increase happened rather late. Now he ends with a question, is it related to AI? But from that same post from Elizabeth Christensen, he points out the August patch for Postgres had 28 CVEs, so this is probably the primary reason that there was relatively low activity at the feature freeze mark compared to other releases, because people were probably busy reviewing and implementing security patches that the work that normally got completed here got shifted late.
3:32So this data suggests that AI may have had a hand in in the feature development for Postgres 19, but it may actually be the CVEs that caused this delay as to when all of the reversions happened and potentially their magnitude, because maybe more features would have been able to reach a stable state and not be reverted if committers didn't have to focus on so many CVEs that were happening.
3:57But if you want to learn more, definitely check out this blog post.
4:00Next Piece of Content why Open Source Always Wins this is from pgdog.dev and pgdog is a sharding pooler. It is an open source project.
4:12So this blog post basically is advocating for open source and why it's a good thing. I thought it was a pretty good read. But the ultimate question is okay, if you're doing open source, how do you make money? And he says free in terms of free and open source means free as in freedom to use it and to make your own choices. But it's not that they're giving everything away for free because he says, quote, it costs a lot of money to build and even more money to operate the code. Because he says if you deploy it, you own it. So yes, it's an open source project, you can choose to take it and install it, but at that point of installation you now own the responsibility of whatever that code is doing.
4:52And he says, quote, you can create a GitHub issue on an open source project and hope it gets resolved by a generous stranger, but at the end of the day you are on the hook to make sure that it does. So for that reason, you know they offer the Enterprise Edition licenses and they have a 15 minute SLA basically to make sure this software works in your environment for you. But if you want to learn more, definitely encourage you to check this out.
5:18Next piece of content what repack concurrently costs while it runs this is from boringsql.com so this is a feature coming in 19 repack and repack concurrently assuming it does not get reverted. And he put it through its paces, comparing it to vacuum full, which entirely blocks the table for reads and writes, as well as the current PGrepack extension and PG Squeeze. And PG Squeeze, its implementation is basically what the new repack and repack concurrently follow. So the implementation does use logical decoding to keep track of changes. And it's using a replication slot to basically have a snapshot for when it started.
6:01It copies the whole table over and then it replays all the wall that's been maintained to get the table in sync with the old table.
6:11And at the very end when it's swapping things back, it needs an access exclusive lock on that table. It's very brief, but of course this can impact reads and writes during that final phase. And out of this comparison between the three other methods of resizing the table, repack concurrently came out pretty far ahead. Shockingly even faster than vacuum full in terms of speed. The wall generated was in line with PG squeeze because they have the same type of implementation. But the peek extra disk was kept rather small too compared to PGfreeze because apparently it releases the wall files earlier.
6:48And it looks like this was done on a roughly 18 gigabyte table. And he also did a repack operation when 3,000 single row updates were hitting per second. And this extended the duration of the repack by about 20 seconds or so and also increase the amount of wall generated. So he says something to be aware of is that vacuum is held back during these repack operations, so you're going to have dead tuples accumulate. But it looks like because it is using a logical replication slot, it can impact other databases and other tables when holding vacuum. So basically you want to keep activity to a minimum on the database as a whole while you're running a repack operation on a particular table.