NS Nikolay Samokhvalov Nikolay Samokhvalov Founder of Postgres.ai, working on tools for safe schema changes and query optimization in Postgres.

“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.”

Postgres FM · Hands-On Engineering Podcasts · November 2026

“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

Context

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.

Transcript

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.

More from Postgres FM