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 advice is upvoted here. It feels like children playing in a sand pit, and then one of the children dumps a box of rat poison on the ground, and some kid says how rat poison is actually good for you because it contains minerals or something. So they all start quickly scarfing it down. You try to tell them rat poison is bad for them, and then several of the kids start defending rat poison, with one lecturing you for being so negative about rat poison. I guess I should just let the kids poison themselves, but it's a terrible thing to watch.
There are way more terrible ideas than good ones, and that means treating all of them equally is a one-way road to HN losing the one thing it has going: new ideas.
Feedback like root comment is important to keep pushing ideas forward, instead of a loop.
I would honestly love to educate people here. But when the rabble come together to downvote you and dismiss what you're saying, the general perception from any reader is going to be that I'm wrong because so many people are disagreeing with me. Despite the fact that I'm literally an expert and they're not. So it's useless. (And just hurts my soul.)
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.
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
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.
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,
Caching can make sense in more situations than "too many users running the same query at once". For basically anything slow that you'd like to make faster, you can weigh the downsides of caching against the downsides of optimizing its performance in other ways. In a startup context, often some (judicious) caching is preferable to spending a bunch of time carefully optimizing some code that's going to change or be thrown out in a month anyway.
Many of the technical blog posts that are most up-voted here on HN would be best described as content marketing. That the posts describe something technical is almost incidental to the point of making you aware that the company writing the post exists.
HN eats up all sorts of these posts from companies selling backend-as-a-service, low-code-web-UI-as-a-service, unreliable-replacement-for-Heroku's-free-tier-as-a-service, and so on...
Yes, and honestly his "why" section really reads like "A hammer can do everything a screwdriver can, and I really like my hammer so I'll use it to push screws into planks".
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.
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.
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
It gives me anxiety how much truly awful advice is upvoted here. It feels like children playing in a sand pit, and then one of the children dumps a box of rat poison on the ground, and some kid says how rat poison is actually good for you because it contains minerals or something. So they all start quickly scarfing it down. You try to tell them rat poison is bad for them, and then several of the kids start defending rat poison, with one lecturing you for being so negative about rat poison. I guess I should just let the kids poison themselves, but it's a terrible thing to watch.