Postgres 19 Released! | Scaling Postgres 444

Episode 444 • November 22, 2026 • 00:18:25
Postgres 19 Released! | Scaling Postgres 444
Scaling Postgres
Postgres 19 Released! | Scaling Postgres 444

Nov 22 2026 | 00:18:25

/

Hosted By

Creston Jamison

Show Notes

In this episode of Scaling Postgres, we discuss Postgres 19 being released, how to upgrade the recent minor version releases, more detail about the CVEs and the hidden costs of temp tables.

To get the show notes as well as get notified of new episodes, visit: 
https://www.scalingpostgres.com/episodes/444-postgres-19-released/

Want to learn more about Postgres performance? Join my FREE training called Postgres Performance Demystified here: https://www.scalingpostgres.com/courses/postgres-performance-demystified/

View Full Transcript

Episode Transcript

[00:00:00] Well, it's been a long time coming, but Postgres 19 is finally here. I'm recording this on November 19th and PostgreSQL 19 is released and I have to say even though they had the reverts, there is a lot of good stuff in this release and we'll be talking about that. But I hope you, your friends, family and co workers continue to do well. Our first piece of content PostgreSQL 19 is released. This is from PostgreSQL and I think it's appropriate they mentioned, I would say four top features in here. They don't explicitly say that, but basically what they mention at the top is Repack concurrently for removing table bloat concurrently. The new PGPlanNadvice extension to basically lock plans in place or give the planner guidance without using SQL hints as well as support for read your writes on standbys and better get or create behavior by avoiding the network round trip. Basically this is insert and on Conflict select, but let's get into a little bit more detail here. So basically repack now replaces what Vacuum Full did and what cluster commands do. So it does both of these jobs and and it can do it concurrently, which is awesome. Basically rewriting tables to eliminate bloat. And of course cluster allows you to rebuild a table against a particular index so you have correlation between the physical rows and a logical column. Then we have the PGPlanNadvice extension as well as the PGStache Advice extension. So it allows stabilization of plan choices and also alter different plans using the Plan Advice mini language. The Stash Advice extension stores this advice and automatically applies it to queries based upon the query identifier. So you can do this without having to change your code. You don't put SQL in the comments. [00:02:01] It's basically a configuration. When you see this query, make sure to carry out this particular plan. Autovacuum can now vacuum index using parallel workers that's controlled by the Autovacuum Max Parallel workers setting as well it has that new scoring system to be able to decide which tables get vacuumed next, which maybe this will reduce tables being left behind because some other tables are hogging all the vacuum resources. It says queries that read a table can now automatically mark pages as all visible in the visibility map during execution. [00:02:36] So this would reduce the work that vacuums need to do and this is great. Vacuumdb Analyze only now analyzes partition tables when no tables are specified, so vacuuming those partition tables is important. And of course we've got some new statistics views such as pgstatlock for per lock type statistics, pgstat Recovery for recovery status, and pgstat Autovacuum scores to determine how autovacuum is prioritizing tables. They have an I O option for explainanalyze and auto explain settings, as well as a new PG stat wall as well. There's more enhancements to logical replication where as soon as you create the slot it actually elevates the wall level to logical. This is the huge one for me. Logical replication can now copy over sequence values, but again as I remember it, it doesn't do it all the time. You have to manually say go ahead and refresh them. But this is clearly better than running your own scripts and trying to do it. There's been some enhancements to Postgres, Foreign data wrapper and a few other publication and subscription settings, and this is another big one in my opinion. Adds Read your writes consistency with the new waitforlsn command. [00:03:54] So basically a standby can wait for a particular LSN has been replayed before executing the query. So this could be highly beneficial for a lot of people. There's been some improvements on queries and foreign tables, and this is another huge one. Insert on conflict do select so this lets you do a get or create pattern, a new JSON output for a copy, and the SQL JSON path language adds string methods. They also mention improvements in the performance of foreign key checks and during a bulk load inserts were nearly two times faster. [00:04:29] There's also more planner optimizations like converting not in into more efficient anti joins. That's pretty huge. You don't have to rewrite those now. Oh they say when null values are not present as well as performing eager aggregation before joins to reduce the number of rows to process again. I remember having to rewrite some queries to help with this and the new Asyncio subsystem in 18. Now if you're using workers, it sets a min worker and a max worker setting so it can adjust it. So definitely a lot of huge improvements in 19. It's great to have it released. If you want to learn more, definitely check this out. I'm sure the next week or two there will be tons of blog posts going through each of these in detail, but onto some less Happy news is talking about all the patches that happened last week and particularly how you can upgrade Postgres without running into issues Now I think the best post talking about all of these security releases was this one. It also has a video too, but Postgres 18.7 security release, the impact of CVE2026, 6460 and other memory corruption issues. This is from pganalyze.com and also part of Lucas's five minutes of Postgres. So he has the video here, but he actually took these 52 and he said he used Claude Fable and Opus to do a human review of it and he categorized some of the vulnerabilities. The first he set out on its own is a pre authorization denial of service. So if you run Postgres on a public Internet, this is the one you would need to be concerned about and need to patch as soon as you can. Otherwise you may be opening yourself up to a denial of service attack. [00:06:13] The next he goes through arbitrary code execution due to memory corruption. So he lists all of these here. Some issues that can happen from users creating objects, some privilege escalation without memory corruption, as well as some attacks from a compromised remote server. This would be something doing logical replication or Postgres foreign data wrapper and then some data exposure and privilege check bypasses as well as more denial of service as well as client tools. So that's the other thing to remember when you're patching Postgres to also patch the client tools themselves on any application or worker servers you have. Now it sounds like from all of this you don't need to worry about a Postgres on the Internet becoming vulnerable immediately. It's basically just a denial of service attack. But. But you do need to be concerned about if you allow users to connect to your Postgres database and execute SQL. That's where a lot of these could potentially be vectors for compromising your database. Now he did call out particularly the 6460 CVE here that has to do with composite types and they actually had to change a bit of the interface that can impact extensions. [00:07:28] And he calls this a pretty invasive fix. And he shows the commit messages here. But we'll look at a few blog posts explaining this in more detail. But because of this change, he said PGRX had to make a release to make itself compatible with the API and particularly with extensions. You want to update your extensions as well and restart the server when you update these packages. [00:07:54] And they say that the PGDG Debian packages do this upgrade correctly, they stop the old server, replace files and start it again. When they tested the RPM packages, the sequence might not be quite right. But again we'll look at a blog post related to that. But if you want to learn more about this Definitely check out this blog post. The next one. Postgres 18.7 miner breaks ABI compatibility Again this is from ardentperf.com and it's basically from this CVE that Lucas was talking about and basically identifies, you know, you need to update your extensions. And then he released this one. Postgres 18.7 Debian and Red Hat packagers protect you and this means trying to update the packages as well as the database and restart everything. [00:08:42] And he references Lucas's post, which we just did, as well as Devram's blog which we'll look at. [00:08:48] And this is PostgreSQL November 2026 minor releases update the Server and Extensions so this is from peopleplanetpostgresql.org he says, you know, update Postgres and every extension together in one transaction. So basically do sudo dnf update or sudo zyper update depending upon your distribution. You know, don't hold the server back, don't hold the extensions back, don't skip broken ones, don't try to copy RPMs between machines. [00:09:20] But this blog post talks about the rebuilding of these extensions along with it for the RPM package managers. So check this out if you want to learn more. And specifically with regard to this 6460 CVE, there's a post here turning a 22 year old type confusion primitive into a RCE or remote code execution. This is from maimin teats.net and he goes into more depth into 6460 on how he was able to get a remote code execution with it. So if you're interested in the security perspective and how this was identified, you can definitely check out this blog post. And moving back into performance, the next piece of content. There was another episode of Postgres FM last week. This was on the hidden cost of createtemptable. In this episode Nick and Kirk discussed this topic and it came from Kirk using Oracle where they have global temporary tables and that was what their application was using. And when they switched to Postgres they said okay, well we'll use temporary tables there. And they ran into a number of problems with doing that and they discuss what are the problems with temp tables. I have one snapshot from the video that they post here that actually lists them out. [00:10:35] First, temporary tables only exist on the primary why? Because they are not wall logged and they can't appear on replicas. [00:10:43] Second is that the data is invisible to other sessions, so when you create a temporary table, it's only for your existing database session. No Other session can read it. If you need a temporary table or temporary like table that you don't care about its persistence, you should probably just create a table and make it unlogged. That won't be wall logged, but every session on the database can still interact with it. The next problem with them is dead tuples. They can accumulate vacuum never runs on temp tables. And next is catalog bloat. Because every time you create a temp table you're essentially having to interact with a catalog. And the invalidation process can be particularly onerous and you could encounter lightweight locks with regard to snval writes or snval reads and apparently synval means shared invalidation, but basically the central data object, the catalog of all the tables in Postgres. If you have a lot of temporary tables being created and destroyed, you're going to hit bottlenecks interacting with that common data structure, essentially the catalog, and you'll have increased wait states. And Nick was saying how he had seen some of this where the machine doesn't look like it's working, the CPU is not working that hard, but it's all wait states due to so many objects being created or deleted and having to update the catalog as a result of that. So if you want to learn more, definitely encourage you to listen to the episode or watch the YouTube video down here. [00:12:16] There is also next blog post the hidden costs of create temp table, catalog bloat and lightweight lock Snval write this is from Postgres AI and he goes through the process of actually testing out performance and he has this particular graph that was also in the video and how using temp tables can devastate your transactions per second. So for a particular use case, if you use a CTE with no temporary table you you can get almost 87,000 transactions per second. If you drop it to one tent table per session and on commit delete roads it falls down to a little under 18,000 transactions per second. Or if you truncated each transaction you're down to 4400 transactions per second. Or for each transaction you create a temp table, it's down to less than 4000 transactions per second or even as low as 1500. [00:13:12] And here he talks about when you have tons of connections, some of these lightweight locks that can happen as it's waiting. So if you want more detail as to why you shouldn't use temporary tables, you can definitely consult this blog post as well. [00:13:27] Next piece of content. Your biggest tenant runs someone else's plan. This is from boringsql.com and what he's talking about is when you have prepared statements, the first five executions use custom plans and on the sixth execution it uses a generic plan and it ends up switching to it if the costs are low enough. Well, what that means is that all subsequent plans use that generic plan. And if you have data sku and in his example he's using accounts or tenants or sites. I think if one particular site has so many more readings compared to the next site, that generic plan may not be optimal for it. But you can also think of this in terms of a SaaS app where you have tons of smaller customers and then you've got fewer bigger customers. Well, your generic plan may end up being optimal for all of your smaller customers, whereas it falls apart on the bigger customers. And he discusses this problem in detail, shows examples and basically the resolution is is to rewrite from a query perspective and potentially introducing indexes to make sure that the plans that can be generated work for both sizes of accounts or sites. But if you want to learn more, definitely check out this blog post. [00:14:46] Next piece of content Distributed primary keys. This is from Tapou eh.org and he's following up with his logical replication series and he says if you're going to do distribute your primary keys, how should you do it? And he doesn't say one way is best, but he definitely shows different options and how to choose among them. So if we look at this, you could do one big int sequence per region. [00:15:12] So each region will have its own numbers, but they can still conflict with one another. So in that case you would want to use a composite version that includes the region id. So here you've got the region as part of the key and a bigint. The next option is a fully random uuid, but this is actually the worst option for performance because as we've discussed before, random UUIDs are written all across an index and it just makes the wall huge and diminishes performance. So you definitely want to avoid that. Much better is the UUID version 7 which is timestamp or and you could use this without a region because the version 7 is sufficiently random to not have to include a region and each ID should be unique across your different regions. And the last option is more of a snowflake ID where you have a time based bigint and the region is in the bits. Now we did say with regard to sequences, it is possible that the sequence is not up to date when you do a failover from say a primary to a replica. If those sequences are up to date it will try to recreate IDs that already exist, although it said it is time based so maybe that's not the biggest risk. I guess it's you're vulnerable to clock drift if this potentially happens. But it definitely talks about all the positives and negatives of each one. And if you're needing a distributed primary key, definitely Check out this blog post where he takes everything through its paces and the last piece of content how to reduce PostgreSQL memory usage and cut your cloud bill in half. This is from cortexridge.com and he's talking about a situation where someone has a multi tenant database and every tenant gets their own schema. So Basically they have 432 schemas in total containing 82,000 tables. So that is the big problem because each Postgres back end quote keeps a private cache of the tables it is used so there are columns, indexes, constraints and PostgreSQL never turns this cache. [00:17:22] It is only freed when the connection closes. So when you have 82,000 tables and each of those connections are jumping around all the different tables, it's not like a Postgres backend connection was locked to a schema. It it can query or read from any table because they were using a connection pooler. So how they resolve the situation is basically specify a 10 minute lifetime for the pooler connections because previously their pooler kept each connection open for 24 hours. Am I going from 24 hours to 10 minutes now suddenly they're using approximately half of the memory, so the memory went from 93% down to 50%. So definitely something to keep in mind if you have a lot of tables in your database. I hope you enjoyed this episode. Be sure to check out scalingpostgrows.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 also find an audio version of the show as well as a full transcript. Thanks. I'll see you next week.

Other Episodes

Episode 247

January 11, 2023 • 00:14:25
Episode Cover

Generate Test Data, Faster Archiving, Date Statistics, Useless Indexes | Scaling Postgres 247

In this episode of Scaling Postgres, we discuss how to generate test data, how WAL archiving is faster in PG15, how to set date...

Listen

Episode 29

September 10, 2018 • 00:13:27
Episode Cover

Parallel Indexing, SQL vs. ORM, Logical Replication Upgrades | Scaling Postgres 29

In this episode of Scaling Postgres, we review articles covering parallel indexing, SQL vs. ORM, logical replication upgrades and development DBs. To get the...

Listen

Episode 357

March 16, 2025 • 00:09:58
Episode Cover

Postgres Best Practices? | Scaling Postgres 357

In this episode of Scaling Postgres, we discuss best practices, caching monitoring statistics, a new vector extension called VectorChord and the importance of monitoring...

Listen