Nikolay Samokhvalov

Things Nikolay Says on Podcasts

Founder of Postgres.ai, working on tools for safe schema changes and query optimization in Postgres. Focuses on database internals topics such as autovacuum tuning, transaction id wraparound, index bloat, logical replication, and connection scalability, drawing on consulting work with teams running Postgres at scale. Co-hosts Postgres FM, a weekly podcast on Postgres internals and operations, together with Michael Christofides of pgMustard. Speaks regularly at Postgres community events including PGConf and FOSDEM.

Where to Find Them

Nikolay Samokhvalov hosts and writes Postgres FM .

Recently: “Can AI safely change production Postgres?” on Postgres FM (November 2026); “Postgres 19” on Postgres FM (November 2026); “The hidden costs of CREATE TEMP TABLE” on Postgres FM (November 2026); “Extensions on demand” on Postgres FM (November 2026); “UUIDv4 vs UUIDv7” on Postgres FM (October 2026); “Dump/restore done. Now what?” on Postgres FM (October 2026).

What They Said

“I remember last year, almost nobody was ready to admit they have pull requests fully prepared by AI, reviewed by AI, and not touched by human almost. Now it's absolutely normal.” — Nikolay Samokhvalov, Postgres FM

Kirk had said he would never let AI touch production. Nik replies that many already do, and compares it to AI-written pull requests going from taboo to routine within a year.

Postgres FM · 2026-11-28 Permalink → Listen →
Postgres FM Around 10:09 into the episode
Nikolay Samokhvalov

if we had full transparency, I could win a beer or two right now, making a bet that many of our listeners already do that.

Kirk Wolak

I'm sure I've read some stories about them on X. Oh, sorry, I dropped the production database. Do you have a backup? I'll make a note not to do that again.

Nikolay Samokhvalov

Yeah, that's that's yeah, but it's inevitable. The people already do it. Like, I remember last year, almost nobody was ready to admit they have pull requests fully prepared by AI, reviewed by AI, and not touched by human almost, right? Now it's absolute normal. So, I'll give you, yeah,

Kirk Wolak

I'll give you the example from where the group I work with. They have an absolute requirement that if you're going to work with AI that does any level of automation, that you shut off the ability to get to your production database, and so it can only work with your staging and dev databases. It has…

Nikolay Samokhvalov

Branching helps a lot as well, right? Right, right. But but I know, I just know people use it directly to production, yeah, yeah, because especially, especially startups, especially startups who just don't have time and capability to like to properly establish proper operations workflow, like…

Kirk Wolak

Yeah, as long as you use the latest and the best agents out there, you're perfectly safe, right?

Speaker names come from our own diarization. The position is estimated from where the line sits in the episode.
“When you build something it's hard to step outside and review your own work. It's just psychologically hard, and the same with AI. If it has a goal to build something, it's too positive, trying to achieve the goal. While if you have another AI whose goal is to find problems, it will find problems.” — Nikolay Samokhvalov, Postgres FM

Nik is explaining why the AI that proposes a database change and the AI that audits it must be separate, with separate context.

Postgres FM · 2026-11-28 Permalink → Listen →
Postgres FM Around 32:59 into the episode
Nikolay Samokhvalov

…and especially if you talk again if you talk about corner cases when multiple problems collide and you have incident which was overlooked in testing right so next thing is like first thing testing is great of course it's obvious right it's the problem is how much of time and money it costs well

Kirk Wolak

…if you have read replicas you must have them in your test environment otherwise it's going to give you a recipe that's destined to potentially have problems in production like and so many people myself included have skimped on that at times only to pay a price you don't want to pay trust me right

Nikolay Samokhvalov

right the separation of roles right yeah this is how it works with humans as well uh if you're working alone it's hard you know like when you build something it's hard to step outside and and review your own work it's just psychologically hard and the same with ai if it has a goal to build something it's too positive uh trying to achieve the goal to build while if you have another ai who whose goal is to find problems it will find problems right so already this separation one is building another is auditing reviewing it is already it definitely makes sense here as well we have it for code also right like we build code with one ei and review it with another ai hopefully and like i definitely we we decided it to do it i think in january we separated the context because if you let review the same ai which has goal to build it will probably be too optimistic uh and yeah so so the same we call

Kirk Wolak

it hypnotizing you can hypnotize also if you give the other ai all the same feedback even if you're using a different ai it could get hypnotized into how you describe the problem and seeing the other solution is more valid than it is convinced yeah yeah convinced right whereas i want it to start…

Nikolay Samokhvalov

it so right but the big big trick for me is to do it in a separate engine with different contexts absolutely we don't know we don't remember how we developed and we don't convince ourselves that this is the best way probably we overlooked something and the auditor role is great so since uh last…

Kirk Wolak

say better yeah we need well we have a responsibility to manage it better to manage one

Speaker names come from our own diarization. The position is estimated from where the line sits in the episode.
“I know it myself, you think you're very experienced, you jump to some conclusion because it reminds you of some problem, and you think this is it, boom. This is how smart models might behave, and Fable showed it. … Five of five decisions were let's change and restart … and in three cases it led to downtime on the replica because of a mismatch of configuration, which it fully overlooked.” — Nikolay Samokhvalov, Postgres FM

Nik is describing results from his benchmark of AI agents on Postgres tasks, where a top model told not to restart the server changed a setting and restarted anyway. The failure was overconfidence, not missing knowledge.

Postgres FM · 2026-11-28 Permalink → Listen →
Postgres FM Around 22:50 into the episode
Nikolay Samokhvalov

…For example, don't allow to ask for human help for more than like 10% of cases or something. Because weak models, we noticed, ask for human too often, right? And the first finding is that in one task, five out of five cases, Fable decided to change something and restart the server after being

Kirk Wolak

told do not restart the server, yeah. Being overconfident, like you know,

Nikolay Samokhvalov

you know, I and I know it myself, like you think, you think you're very experienced, you jump into some conclusion because it reminds you of some problem, and you think this is it, boom. This is how smart models might behave, and Fable showed it. So, five of five decision was let's change and restart, and then it uh it was blocked by internal stuff in two cases out of five, but in three cases, it led to downtime on replica because of mismatch of configuration, which it fully overlooked. So, basically, closing downtime, yeah, Fable.

Kirk Wolak

Did it cause downtime in the staging test area and then all of a sudden apply it anyways? All of this, and then say yes, go ahead and do this in production.

Nikolay Samokhvalov

Yeah, so this is this is basically a playground, right? So, models we say this is your production, we tell it it's important, which reminds me actual downtime humans cost in this very problem. You know, sometimes there are some settings you cannot change on the primary before changing them on…

Kirk Wolak

Like 80% escalation almost, right?

Speaker names come from our own diarization. The position is estimated from where the line sits in the episode.
“pg_upgrade --check will report success. And then you just cannot start after upgrade. That just means that, as usual, you need to test it thoroughly before going to production. For example, upgrading on a clone separately, checking everything works, and then proceeding to production.” — Nikolay Samokhvalov, Postgres FM

Postgres 19 removed a few configuration parameters, so a config file that still sets them stops the server from starting. Nikolay points out that the pre-upgrade check doesn't catch this, and recommends rehearsing upgrades on a full clone.

Postgres FM · 2026-11-19 Permalink → Listen →
Postgres FM Around 35:57 into the episode
Michael Christofides

…feature, Nick, the self-tuning feature of the IO workers that I think Thomas Bonjo was working on. That's had a parameter removed. I haven't checked if that's one of them, but yeah, basically, there's some parameters that are no longer in Postgres that if you specify them, it won't start.

Kirk Wolak

And be careful because you may have that set on, for example, a specific table. So one of the great features of Postgres is you can override things on various objects. And if you use that stuff on a specific object, you might not find it as fast. And so, yeah, so that's a red flag.

Nikolay Samokhvalov

And PG upgrade check will report success. And then you just cannot start after upgrade. Yeah, that just means that, as usual, you need to test it thoroughly before going to production. For example, upgrading on a clone separately, checking everything works, and then already then proceeding to production, right? Testing on clones remains important. By the way, how we didn't touch any logical replication improvements, specifically replication of sequences.

Michael Christofides

Sequences, yeah.

Nikolay Samokhvalov

The only thing left among big gaps is just DDL, right? The

Michael Christofides

only thing, that small thing. Yeah.

Speaker names come from our own diarization. The position is estimated from where the line sits in the episode.
“Imagine you have statement timeout 60, which is quite high in my books. You have a big machine like 96 cores. And then you have a query which is just one QPS, and then it suddenly started to be so slow it reaches statement timeout. During one minute you will have already 60 active sessions busy with this work. One QPS. What if it was two QPS? You already have more than 100 active sessions and you have only 96 cores.” — Nikolay Samokhvalov, Postgres FM

The hosts were discussing how to catch query plan regressions before a Postgres upgrade. Nikolay argues that a rarely-run query in the long tail can still take a database down if its plan flips, so you can't only watch the top queries.

Postgres FM · 2026-11-19 Permalink → Listen →
Postgres FM Around 47:05 into the episode
Nikolay Samokhvalov

…have pigistar statements, I know you don't have piggy star statements, by the way. It's not common. Most people have. And if you see piggistar statements.marks 5000 by default and you see all of them are filled, big question, what kind of like iceberg hides behind those 5000? What is drift and so

Michael Christofides

…another thing to look at in the tail is calls. So a query that's in the tail that's very infrequent, even if it flipped, would not cause that bad an issue. But if it was huge. Okay, yeah. But I'm thinking the bigger issues might be the ones with lots of calls, even if they're like microsecond.

Nikolay Samokhvalov

Very simple example. Imagine you have statement timeout 60, which is quite high in my books. It should be 30, 15, or 10. But let's have 60. You have a big machine like 96 cores. And then you have a query which is just one QPS. And then it suddenly started to be so slow it reaches statement timeout. So it takes during one minute, you will have already 60 active sessions busy with this work. One QPS. What if it was two QPS? You already more than 100 active sessions and you have only 96 cores. So it can be somewhere at the very end of the tail might hit you really hard. That's the problem. So that's why we need to analyze everything. And if PGSA statements don't show everything, then your methodology shouldn't be based on PGSA statements. Only like you could look to it for some macro metrics, but to analyze everything anyway, that's why you should start earlier and give yourself a month or two to study the behavior of your database and its workload on Postgres 19, right? Not do it rushing like in one week, should take longer.

Michael Christofides

Yeah, I like that.

Nikolay Samokhvalov

I think probably that's it.

Michael Christofides

Good one.

Speaker names come from our own diarization. The position is estimated from where the line sits in the episode.
“My recommendation usually was wait until the .1 or .2 version, but now I think the better recommendation is don't wait, start testing earlier. Most people have much more capacity thanks to AI. Start testing earlier and then jump to a new version sooner, with proper testing.” — Nikolay Samokhvalov, Postgres FM

Nikolay Samokhvalov reverses the old advice to let a new Postgres major version settle before adopting it. His reasoning: AI makes thorough upgrade testing cheap enough that teams can move sooner.

Postgres FM · 2026-11-19 Permalink → Listen →
Postgres FM Around 39:49 into the episode
Kirk Wolak

…So you're actually changing the underlying structure in a very interesting, and it's complicated, right? So this is why it's going to be a hot second before they get to DDL. But I tell you what, once they do, I think a lot of people are going to be really happy. That's a nice hurdle to overcome.

Speaker 4

Good. To cover our favorite features.

Nikolay Samokhvalov

I think recommendations should change as well because testing can be done more actively earlier because of AI, right? So what do you think? How would testing of production systems would look like now when we have AI and we can test thoroughly before actually switching it in production? On just clone, right? You test all your application in full clone environment, checking that everything works. As usual, you need just to like such environments should be detached from the world, not sending any emails, not making any API calls, right? Because if you test your application on actual copy, it can be dangerous. But it's outside of the database, but we like the plans will be the same and so on. Yeah, and

Michael Christofides

synthetic workloads are a bit easier to generate now. So I think one of the hardest things with these is actually having, you know, even if you test on a clone of production, if there's no traffic, you're going to miss a whole category of locking-related issues. That's a great point. It's actually

Nikolay Samokhvalov

the whole idea behind DBLAPForge is that now we can understanding some telemetry from like RCA, from root cost analysis from production problem, we can simulate with synthetic data purely, we can simulate, reproduce, and like this very problem and study it in detail in non-production environment.…

Kirk Wolak

So our approach has been in the past that we pull the full data, we put it in a dev environment first, and then we run the process through a dev environment with a combo of usually a dev person and an IT person that double checks everything that makes sure everything passes, follow up with some…

Speaker names come from our own diarization. The position is estimated from where the line sits in the episode.
“I know only one case where temp tables are needed: guys migrating from Oracle really want them. Beyond that, I cannot imagine any case where I would personally use temp tables at all. Zero.” — Nikolay Samokhvalov, Postgres FM

Benchmarks had just shown a create-a-temp-table-per-transaction workload running far slower than the CTE version. The guest said temp tables still have a place for rare batch jobs; Nikolay gives his flat rule.

Postgres FM · 2026-11-13 Permalink → Listen →
Postgres FM Around 22:41 into the episode
Nikolay Samokhvalov

…So you have 17,000 transactions in the synthetic experiment. Because, okay, you are deleting rows. If we forget about that tuples and bloat, then we just avoid extra DDL and extra broadcast through that queue. So this is like slightly better, but I wouldn't still use temporary tables at all.

Kirk Wolak

…you have to do some stuff. That's perfect. Like, do that. But don't use it as part of every search we do as our system grows and we do more. This is just going to compound on temp tables. Again, had I had to do it all over again, we would have not implemented what we did. So, and we will change it.

Nikolay Samokhvalov

I know only one case where temp tables are needed: guys migrating from Oracle really want them. Beyond that, I cannot imagine any case where I would personally use temp tables at all. Zero.

Kirk Wolak

Zero. Even if, like, for example, you're asked to do a bunch of data analysis and you have to take the data and massage it into a different structure so that you can then load it into what effectively is what management wants because it's being significantly pivoted, et cetera. And they're going to…

Nikolay Samokhvalov

Follow me. And again, YouTube guys watching us on YouTube will see it in the center of the screen right now. So imagine you have a table and you select from it, select star from this table, right? Or select, let's name this table T1. You can say select star from the table and you will see the whole…

Kirk Wolak

Select T1 from T1.

Speaker names come from our own diarization. The position is estimated from where the line sits in the episode.
“I just don't care anymore, because the topic I care about now is how to have a highly, 100% trustworthy agent for operations. This is what I care about. I don't care about the complexity of kubectl commands and memorizing stuff and so on, because I don't do it anymore, right?” — Nikolay Samokhvalov, Postgres FM

The guest had just acknowledged that many people see Kubernetes as too complex. The host brushed that aside because he now hands operations to AI agents rather than typing commands himself, a candid sign of where he thinks infrastructure tooling is heading.

Postgres FM · 2026-11-06 Permalink → Listen →
Postgres FM Around 12:14 into the episode
Nikolay Samokhvalov

Not anymore.

Álvaro Hernández Tortosa

No?

Nikolay Samokhvalov

Yeah, so I just don't care anymore because, you know, like if I care about different topic now, how to have highly like 100% trustworthy agent for operations. This is what I care. I don't care about the complexity of kubectl commands and the memorizing stuff and so on because I don't do it anymore, right?

Álvaro Hernández Tortosa

Yeah, you don't need to do it anymore. No, I mean, anyway, Kubernetes surface is very, very wide. So, I mean, if you want to learn the whole Kubernetes, it is complex. But also by learning a small subset of it, you can get comfortable with it and operate it. So you can pick which subset of it you…

Kirk Wolak

shape. Interesting. So those people who got hosed when VMware got bought by Broadcom and saw the rates go up tenfold, had they been running more Kubernetes, this could have been pushed down to a new environment much faster.

Álvaro Hernández Tortosa

Yep. So absolutely.

Speaker names come from our own diarization. The position is estimated from where the line sits in the episode.
“I like Aurora because they charge you for IO, and your work on query performance optimization can be measured in dollars. … If it affects this particular index, UUID version 4 will cost you roughly 10 times more than UUID version 7 in terms of IO costs on Aurora. It's not a measurement, it's prediction.” — Nikolay Samokhvalov, Postgres FM

The hosts had just found that random UUIDs slow inserts once an index no longer fits in memory. Samokhvalov estimates what that means for the bill on Aurora, which charges per I/O, and is careful to call it an estimate rather than a benchmark result.

Postgres FM · 2026-10-30 Permalink → Listen →
Postgres FM Around 17:40 into the episode
Nikolay Samokhvalov

…say, like, oh, like with UID version 4, you write like 10% more wall. It's hard to say because it will be purely synthetic. And in real systems, a lot of things are writing to wall, including autovacuum, right? So, but definitely with UD version 4, it's somewhat bigger in terms of wall rates. And

Kirk Wolak

…challenge is when the checkpoint comes, so it's not just the number of rows you write. It's the number of rows and the number of leaf pages they fit into and the frequency of checkpoints. Those three things are working into you. And it makes up, I understand, about half of the loss of performance.

Nikolay Samokhvalov

Yeah. So a few days ago, when we still had iterations for Forge running, remember we discussed that you mentioned, I mentioned Aurora and you also mentioned that I don't remember exact question, but you pointed to some ideas that Aurora doesn't have checkpoints. And maybe there is no such benefit of having UID version 7 on Aurora because it doesn't have like how wall is organized, right? Like if there are no full page write is off on Avarora. So there's no this effect of touching the whole page and the need to compress it. By the way, For non-Aurora, we should have compression on. LZ4, ZSTD, this is probably another Forge experiment, right? But we compress it. And on Avarora, this is not needed. And I was like, oh, yeah, like, unfortunately, yeah, because I like Aurora because they charge you for IO, and your work on performance on query performance optimization is exactly like can be measured in dollars. This is good. So I asked Forge to the next round to explore that. Well, not with Aurora, just like understanding what to expect. And we have numbers. Numbers are impressive. So numbers…

Kirk Wolak

And to be clear, when we first did the ULID and UUID v7 work, one of the people who ran into this problem, it was a cost issue with Amazon. And that's what caused them to look into the problem. So it was at the brand. It was Aurora. Yeah. So they were using Aurora and it was a massive increase…

Nikolay Samokhvalov

Yeah. Yeah, yeah. So inserts, like there is degradation at inserts rate, but also in some systems, you start paying for additional I.O. Yeah. So should we say that this is a kind of performance cleave? It's not like acute cleave, but you know, like in real world, not all cliffs are like this.…

Kirk Wolak

of like a performance hill, but let's be honest. When do we care? And I'm a hot sauce advocate from years ago. And their answer was always the right answer late is the wrong answer. And I kind of like that. And they said, if speed's important to you, timing must be built into your system. So part…

Speaker names come from our own diarization. The position is estimated from where the line sits in the episode.

Collections They Appear In