Jul 5, 2026 · 15 min · 12 segments
In this episode of Scaling Postgres, we discuss the dangers of too many tables, don't worry about extending checkpoint\_timeout, a disaster recovery process, and non-repeatable sums with floating…
Creston JamisonHost
This is from cyberduck-postgresql.com. And he's talking about a situation that a customer was having that they were working with where they had two problems.


And second, they had long-running queries that hogged the CPU and delayed the application.

So what they did to adjust the out-of-memory killer was disable memory overcommit.

And he also thought it might have been issues of other software running on the machine, but that really wasn't the case.

And he says usually when you have high memory usage in Postgres, it's because you set your shared buffers too high, or maybe you have too many connections and you set your work memory too high.

or maybe you're using too much memory for parallel workers, or you have large binary data or JSON values, or even geometries that you're working with.

But they started looking at memory context dumps, and they actually found this entry for cache memory context was really high, almost half a gigabyte.

And this is permanent storage for the relcache, catcache, and related modules.

And the catcache is metadata tables, or the catalog entries, and the relcache is caches of the descriptions of the relations.

So it's basically on how many tables and other objects you have in the database.

And this is per backend, so essentially each backend process was accruing almost half a gigabyte of RAM in the cache memory context.

I don't have anywhere near 10,000 tables, but still a little bit more than I would like.

Anyway, with tens of thousands of tables and long-lived database connections touching more and more of them, the cache grew larger and larger.

And he shows an example here of simulating 20,000 tables with 20 columns each.

He looked at the size, and it was around 4 kilobytes, but when he started doing queries of each of them, the cache memory context grew from 4 kilobytes to 221 megabytes.

Well, try to reduce your connection counts and use the connection pooler instead if you need a lot of connections to the database.

Or maybe try setting idle session timeouts so if nothing's going on with those backends, they can be reaped, which basically frees up some of the memory.

This is from cyberduck-postgresql.com. And he's talking about a situation that a customer was having that they were working with where they had two problems.


And second, they had long-running queries that hogged the CPU and delayed the application.

So what they did to adjust the out-of-memory killer was disable memory overcommit.

And he also thought it might have been issues of other software running on the machine, but that really wasn't the case.

And he says usually when you have high memory usage in Postgres, it's because you set your shared buffers too high, or maybe you have too many connections and you set your work memory too high.

or maybe you're using too much memory for parallel workers, or you have large binary data or JSON values, or even geometries that you're working with.

But they started looking at memory context dumps, and they actually found this entry for cache memory context was really high, almost half a gigabyte.

And this is permanent storage for the relcache, catcache, and related modules.

And the catcache is metadata tables, or the catalog entries, and the relcache is caches of the descriptions of the relations.

So it's basically on how many tables and other objects you have in the database.

And this is per backend, so essentially each backend process was accruing almost half a gigabyte of RAM in the cache memory context.

I don't have anywhere near 10,000 tables, but still a little bit more than I would like.

Anyway, with tens of thousands of tables and long-lived database connections touching more and more of them, the cache grew larger and larger.

And he shows an example here of simulating 20,000 tables with 20 columns each.

He looked at the size, and it was around 4 kilobytes, but when he started doing queries of each of them, the cache memory context grew from 4 kilobytes to 221 megabytes.

Well, try to reduce your connection counts and use the connection pooler instead if you need a lot of connections to the database.

Or maybe try setting idle session timeouts so if nothing's going on with those backends, they can be reaped, which basically frees up some of the memory.
The rest of this transcript — segmented and speaker-labeled, so you land on the exact moment something was said
Search every transcript — by keyword, by phrase, or by meaning, across every show Radar indexes
Trends — what is surging across podcasts, measured against its own baseline
Alerts — when a name you follow appears in a newly indexed episode
No account is needed to search Radar.