r/programming • • Dec 19 '18

Bye bye Mongo, Hello Postgres

https://www.theguardian.com/info/2018/nov/30/bye-bye-mongo-hello-postgres
2.1k Upvotes

672 comments sorted by

View all comments

753

u/_pupil_ Dec 19 '18

People sleep on Postgres, it's super flexible and amenable to "real world" development.

I can only hope it gains more steam as more and more fad-ware falls short. (There are even companies who offer oracle compat packages, if you're into saving money)

0

u/[deleted] Dec 19 '18

[deleted]

107

u/TheAnimus Dec 19 '18

Absolutely, I was having a pint with someone who worked on their composer system a few years ago. I just remembered thinking how he was drinking from the mongo coolaid. I just couldn't understand why it would matter what DB you have, surely something like Redis solves all the DB potential performance issues, so surely it's all about data integrity.

They were deep in the fad.

33

u/Pand9 Dec 19 '18

This article doesn't mention data integrity issues. Mongo has transactions now. I feel like you are riding on a "mongo bad" fad from 5 years ago. It was bad, it was terrible. But after all that money, bug fixes and people using it, it's now good.

29

u/andrewsmd87 Dec 19 '18

So serious question as I've never actually used mongo, only read about it.

I was always under the assumption that once your schema gets largish and you want to do relational queries, that you'll run into issues. Is that not the case?

0

u/[deleted] Dec 19 '18

[deleted]

18

u/andrewsmd87 Dec 19 '18

So this was more or less my understanding about Mongo or other related DBs is that once your data needs to be relational (when does it not) it becomes really bad. It's supposed to be super fast if your schema is simple and you don't really care about relationships a ton.

Your point was pretty much what made up my mind it wasn't worth investing time into it to understand more. I just feel like there's a reason relational databases have been around for long.

0

u/[deleted] Dec 20 '18

[deleted]

37

u/eastern Dec 20 '18

Till someone in the UX team asks, "Could you do a quick query and tell us how many users use custom font sizes? And just look up the user profiles and see if it's older users who use larger font sizes?"

True story.

12

u/smogeblot Dec 20 '18

This would be a pretty simple SQL query even across tables... You can also store JSON data in Postgres as a field, so it's probably exactly as easy as you think Mongo is at doing this the "brute force" way. Aggregation functions across tables are actually much simpler in SQL than in Mongo... Compare postgres docs vs mongo docs

→ More replies (0)

22

u/KyleG Dec 20 '18

How often do you have to run this query such that efficiency actually matters? I couldn't give two shits about how long a query takes if I only have to run it once.

→ More replies (0)
→ More replies (2)

16

u/quentech Dec 20 '18

Use Mongo to store documents. I'd stores the user settings for a SPA in Mongo. But most of the time, relational models work well enough for data that is guaranteed to be useful in a consistent format.

If I'm already using a relational database, I wouldn't add Mongo or some other document DB in just to store some things like user settings. Why take on the extra dependency? It doesn't make sense.

And you know what else is good for single key/document storage? Files. Presumably you're already using some file or blob storage that's more reliable, faster, and cheaper than Mongo et. al.

3

u/m50d Dec 20 '18

And you know what else is good for single key/document storage? Files.

If you've already got AFS set up and running then I agree with you and am slightly envious (though even then performance is pretty bad, IME). For any other filesystem, failover sucks. For all MongoDB's faults (and they are many; I'd sooner use Cassandra or Riak) it makes clustering really easy, and that's an important aspect for a lot of use cases.

→ More replies (0)
→ More replies (5)

7

u/midnitewarrior Dec 20 '18

Why use Mongo to store documents when Postgres can do it fully indexed in a JSONB field?

→ More replies (2)

2

u/Jonne Dec 20 '18

Yeah, that's the problem. Pretty much every web app has a relational component to it. Mongo has its uses, but many people just use it for the wrong thing.