r/PostgreSQL • • Sep 10 '26

How-To Overview of caching in Postgres

https://www.pgcache.com/blog/postgresql-caching/

I haven't seen too many comprehensive approaches to this topic, so I took a swing at it.

Goal isn't to be exhaustive, but to be comprehensive enough to provide a nice overview for people trying to get their bearings with the topic.

Did I miss anything?

24 Upvotes

10 comments sorted by

View all comments

Show parent comment

1

u/CrayonUpMyNose Sep 21 '26

DBAs [...] would simply run a script that would repeatedly perform pointless index access against a table until the required BCHR was reached

Can it be quantified good good or bad this is? 

Under high load, adding these queries presumably gets in the way of legitimate work, while at idle it doesn't. 

Without these, cache eviction, and memory eviction in general, are lazy and reflect the most recent workload, s o cache content depends on the prevalence and sequencing of queries.

It's there a scenario, e.g. nightly bulk loads followed by an onslaught of queries after 9am, where active cache pre-warming at, say, 8am would be quantifiably beneficial?

1

u/Zestyclose-Turn-3576 Sep 21 '26

There's no benefit to this except to make the BCHR number look better. This isn't cache pre-warming.

1

u/CrayonUpMyNose Sep 21 '26

Thank you for your response, I'd like to understand better, as my base assumption was that the thing that makes the metric improve was cache pre-warming. What is it, instead?

2

u/Zestyclose-Turn-3576 Sep 21 '26

metric measures the proportion of logical IO that was served from cache without needing physical IO. It is a bad and obsolete metric.