News for hackers. Stuff that matters.
Re:Goodbye MongoDB, Hello PostgreSQL (2015) by amenod on Thursday March 11, 2021 @02:53AM (#26421451)
I had a project where I just needed to be saving a constant flow of data (id + 100 bytes records) somewhere, no persistence needed, no sharding (single machine) - but lots of it. I first turned to Redis and it worked nicely, but since I had PostgreSQL running, I made a performance test with it too. To my surprise, once I optimized both (memory only, pg WAL disabled, persistent connections,...) there was almost no difference in insert rate, so I ended up using PgSQL only.

This is anecdotal, of course, and it is possible that I simply didn't optimize Redis enough (though I did give it my best!). Let me also say that Redis is great otherwise, it was just in this specific case that PostgreSQL surprised me and fulfilled the need itself.

Re:Goodbye MongoDB, Hello PostgreSQL (2015) by HelloNurse on Thursday March 11, 2021 @05:37AM (#26422506)
Your data-saving test was probably limited by how fast you could save to disk a roughly equal amount of data with the two databases; queries might work and perform more differently.
Re:Goodbye MongoDB, Hello PostgreSQL (2015) by amenod on Thursday March 11, 2021 @09:03AM (#26424094)
That's what I meant by "no persistence needed". In both cases, I wasn't actually saving anything to disk. I needed an in-memory storage for a never-ending stream of incoming data that would be read (and purged) by a separate process, no biggie if the data got lost occasionally.

I also simply inserted and read the data, no complex queries or anything. Key-value store is all I needed and for this particular case PostgreSQL was as good at it as Redis.

Re:Goodbye MongoDB, Hello PostgreSQL (2015) by kinos on Thursday March 11, 2021 @03:21PM (#26428548)
Why did you use a database instead of just creating a global map and running in memory? Sharding?
Re:Goodbye MongoDB, Hello PostgreSQL (2015) by amenod on Friday March 12, 2021 @03:30AM (#26433408)
No - different processes were reading and writing.

And once you implement a global map which is accessible from multiple processes, you might as well use an existing solution, like Redis. Or, as I've learned, pgSQL - which gave me the same performance with less moving parts (because I was already using it) when I disabled WAL.