Live data from Hacker News

You Don't Need a Dedicated Cache Service – PostgreSQL as a Cache (2023)

martinheinz.dev

61–70 of 82 posts

Re: You Don't Need a Dedicated Cache Service – PostgreSQL as a Cache (2023)

#61

Sometimes I feel like the articles posted here are elaborate trolls. Like they wanted to know what the purpose of a cache is and how/when to implement one, but they didn't want to do research, so they came up with the worst idea they could imagine and blogged about it, hoping someone on HN would tell them the right way (or just laughing at people trying to correct them). It gives me anxiety how much truly awful advic…

Do you have specific criticisms? There are myriad and varied different use cases for a cache. I’ve used Postgres in a pinch. It’s fine, for certain things. I’ve used a lot of other caches as well that would be highly inappropriate for the situations I’ve used Postgres in.

In my experience there are far more highly-overwrought bloated architectures deployed than there are overly-clever minimalist ones. Everyone wants to put the cool tools on their resume.

Re: You Don't Need a Dedicated Cache Service – PostgreSQL as a Cache (2023)

#62
post #20

Calling Postgres experts: Why, exactly, do we need to put a memory cache such as Redis in front of Postgres? Postgres has its own in-memory cache that it updates on reads and writes, right? What makes Postgres' cache so much worse than a dedicated Redis?

As far as I know there is no way to tell Postgres to keep a particular index or table in memory, which is one reason to be weary of using one PG instance for many varied workloads. You might solve this by earmarking workload-specific replicas, though. If you can keep your entire working set in memory, though, then it probably doesn't matter that much.

Being wary for too long can make one weary.

Re: You Don't Need a Dedicated Cache Service – PostgreSQL as a Cache (2023)

#63
post #61

Sometimes I feel like the articles posted here are elaborate trolls. Like they wanted to know what the purpose of a cache is and how/when to implement one, but they didn't want to do research, so they came up with the worst idea they could imagine and blogged about it, hoping someone on HN would tell them the right way (or just laughing at people trying to correct them). It gives me anxiety how much truly awful advic…

Do you have specific criticisms? There are myriad and varied different use cases for a cache. I’ve used Postgres in a pinch. It’s fine, for certain things. I’ve used a lot of other caches as well that would be highly inappropriate for the situations I’ve used Postgres in. In my experience there are far more highly-overwrought bloated architectures deployed than there are overly-clever minimalist ones. Everyone wants…

So for one we do cache to remove load from dbms, then makes a lot of sense to remove load from dbms by giving it the load of cache too, another thing might be that separate services might be optimised for different tasks, redis is built with being first class in memory cache service, postgres is built with different first-class usage in mind, another one I can think of is resources, I can scale redis and dbms independently as their specific needs change

Overall for me this cache in postgres is a bad idea too

Re: You Don't Need a Dedicated Cache Service – PostgreSQL as a Cache (2023)

#64

Sometimes I feel like the articles posted here are elaborate trolls. Like they wanted to know what the purpose of a cache is and how/when to implement one, but they didn't want to do research, so they came up with the worst idea they could imagine and blogged about it, hoping someone on HN would tell them the right way (or just laughing at people trying to correct them). It gives me anxiety how much truly awful advic…

I was working at a company where we had stupid things from the tech world as loading message for slack, like “parsing html with regex”. I think “caching in postgres” might deserve a spot there too

Re: You Don't Need a Dedicated Cache Service – PostgreSQL as a Cache (2023)

#65

Sometimes I feel like the articles posted here are elaborate trolls. Like they wanted to know what the purpose of a cache is and how/when to implement one, but they didn't want to do research, so they came up with the worst idea they could imagine and blogged about it, hoping someone on HN would tell them the right way (or just laughing at people trying to correct them). It gives me anxiety how much truly awful advic…

Very dramatic. No actual technical arguments.

It's easy to envisage systems where this would have no negative impact whatsoever.

Re: You Don't Need a Dedicated Cache Service – PostgreSQL as a Cache (2023)

#66
post #24

Why wouldn't you simply use SQLite (or some other in-memory flavor of SQL) instead of hacking the main Postgres db and adding load to the primary instance? The author makes a valid point that there's something nice about using familiar tooling (including the SQL interface) for a cache, but it feels like there are better solutions.

Because SQLite is in process. Usually, when you start thinking about cache, you have more than one application server. Each application server running its own cache make cache invalidation a nightmare (I worked in a company where one genius did that and caused a lot of troubles). Don't show me any sqlite replication things because that's not how you want your cache to work.

My issue with running PostgreSQL as cache would be its thread per connection model and downsides of MVCC for cache.

Re: You Don't Need a Dedicated Cache Service – PostgreSQL as a Cache (2023)

#67
post #61

Earlier quoted context omitted.

Do you have specific criticisms? There are myriad and varied different use cases for a cache. I’ve used Postgres in a pinch. It’s fine, for certain things. I’ve used a lot of other caches as well that would be highly inappropriate for the situations I’ve used Postgres in. In my experience there are far more highly-overwrought bloated architectures deployed than there are overly-clever minimalist ones. Everyone wants…

So for one we do cache to remove load from dbms, then makes a lot of sense to remove load from dbms by giving it the load of cache too, another thing might be that separate services might be optimised for different tasks, redis is built with being first class in memory cache service, postgres is built with different first-class usage in mind, another one I can think of is resources, I can scale redis and dbms indepen…

I see this as an issue of scale. HN loves to think about infinite scales where there are millions of simultaneous users of systems.

This is rarely the case.

Caching in Postgres is for smaller scale applications where the extra complexity of a dedicated memory cache isn’t worth the extra overhead.

But at least you bring up some actual limits that should to be considered.

DB load: part of the load on a DB is the network connection for the query, but a large part is also finding the data. If you have a complex query, storing a de-normalized form in a cache table would be a lighter load. (Provided that you aren’t limited by the network or number of concurrent connections)

I think that whether or not this is a good idea depends highly upon what scale you’re operating at. For high traffic applications, it’s not a good plan, but if you already have a DB setup and you have a lighter load, I could think of worse solutions.

Re: You Don't Need a Dedicated Cache Service – PostgreSQL as a Cache (2023)

#68
post #67

Earlier quoted context omitted.

So for one we do cache to remove load from dbms, then makes a lot of sense to remove load from dbms by giving it the load of cache too, another thing might be that separate services might be optimised for different tasks, redis is built with being first class in memory cache service, postgres is built with different first-class usage in mind, another one I can think of is resources, I can scale redis and dbms indepen…

I see this as an issue of scale. HN loves to think about infinite scales where there are millions of simultaneous users of systems. This is rarely the case. Caching in Postgres is for smaller scale applications where the extra complexity of a dedicated memory cache isn’t worth the extra overhead. But at least you bring up some actual limits that should to be considered. DB load: part of the load on a DB is the networ…

I mean if you have a light application then maybe you dont even need the cache, at a certain threshold of small you can go ahead with sqlite or access, or excel, of course HN has an issue of scaling, because if we talk about caching then lets talk about situations where talking about caching makes sense,

Re: You Don't Need a Dedicated Cache Service – PostgreSQL as a Cache (2023)

#69

Sometimes I feel like the articles posted here are elaborate trolls. Like they wanted to know what the purpose of a cache is and how/when to implement one, but they didn't want to do research, so they came up with the worst idea they could imagine and blogged about it, hoping someone on HN would tell them the right way (or just laughing at people trying to correct them). It gives me anxiety how much truly awful advic…

OP here:

I was looking around on the internet, found the article, thought it was interesting and posted it.

I think that's being constructive. You on the other hand haven't added anything to the discussion (caching/postgres), but rather are yelling at the clouds.

If you think the article is such a bad idea, provide some alternative links. If you're not in the mood to do that, just go to the next thing you might find interesting on the endless scroll that is HN.

Being a curmudgeon is frankly worse than having sub optimal articles.

Re: You Don't Need a Dedicated Cache Service – PostgreSQL as a Cache (2023)

#70

Sometimes I feel like the articles posted here are elaborate trolls. Like they wanted to know what the purpose of a cache is and how/when to implement one, but they didn't want to do research, so they came up with the worst idea they could imagine and blogged about it, hoping someone on HN would tell them the right way (or just laughing at people trying to correct them). It gives me anxiety how much truly awful advic…

OP here: I was looking around on the internet, found the article, thought it was interesting and posted it. I think that's being constructive. You on the other hand haven't added anything to the discussion (caching/postgres), but rather are yelling at the clouds. If you think the article is such a bad idea, provide some alternative links. If you're not in the mood to do that, just go to the next thing you might find…

The problem is it's so hard to get on the HN Frontpage that stuff that does get there tends to be seen as having value but fools looking at at a foolish idea don't know any better.

OPs post was constructive. It indicates there might be a need for more heavy handed moderation and technical vetting of content before it reaches frontpage.

Post reply on HN