7 ms·
Genuine question: I appreciate the comments about MongoDB being much better than it was 10 years ago; but Postgres is also much better today than then as well.
by jamesrr39 2y ago
Genuine question: I appreciate the comments about MongoDB being much better than it was 10 years ago; but Postgres is also much better today than then as well. What situations is Mongo better than Postgres? Why choose Mongo in 2025?
- 999900000999 2y agoSimple. Postgres is hard, you have to learn SQL. SQL is hard and mean. Mongo means we can just dump everyone into a magic box and worry about it later.No tables to create. But their is little time, we need to ship our CRUD APP NOW! No one on the team knows SQL! I'm actually using Postgres via Supabase for my current project, but I would probably never use straight up Postgres.
- chpatrick 2y agoEven as a JSON document store I'd rather use postgres with a jsonb column.
- tiltowait 2y agoWhy is that? I found Postgres's JSONB a pill to work with beyond trivial SELECTs, and even those were less ergonomic than Mongo.
- chpatrick 2y agoBecause you get the convenience of having a document store with a schema defined outside of the DB if you want it, along with the strong guarantees and semantics of SQL.
- chpatrick 2y agoFor example: let's say you had a CRM. You want to use foreign keys, transactions, all the classic SQL stuff to manage who can edit a post, when it was made, and other important metadata. But the hierarchical stuff representing the actual post is stored in JSON and interpreted by the backend.
- SEJeff 2y agoPostgres supports JSONB natively. It literally speaks mongo line protocol and you can shove unstructured json into it. It has supported this since 9.4: https://www.postgresql.org/docs/current/datatype-json.html https://www.postgresql.org/docs/current/datatype-json.html
- 999900000999 2y agoI don't necessarily agree with the above justifications, but in my experience this is basically why teams pick Mongo. It's easier to get started with.
- SEJeff 2y agoIt’s hard to disagree with you on that part. PG is definitely not free to get starts with and requires a bit of setup (hello pg_hba.conf).
- codr7 2y agoNow there's a truth about MongoDB, it's easy to get started with. But why is that the top priority?
- FridgeSeal 2y agoBecause some devs and teams prioritise “get to prod” above literally all else. Maintainability? Secondary. Security? Secondary. Data-integrity/correctness? Secondary.
- winrid 2y agoYes but updating nested fields is last write wins, and with mongo you could update two fields separately and have the writes succeed, it's not equivalent.
- SEJeff 2y agoCan you provide an example or documentation please?
- codr7 2y agoIf learning SQL is hard, maybe software isn't the best choice of career. Writing code and creating good software requires a lot of mental clarity and effort; that fact is never going to change, not even with AI.
- 999900000999 2y agoBillions upon billions of value have been created just upon the premise that SQL is hard. Firebase by and almost every NoSql technology is based upon this.
- cryptonector 2y agoI thought this was sarcasm till the last sentence. Now I'm not sure.
- riku_iki 2y agoMongo is real distributed and scalable DB, while postgres is single server DB, so main consideration could be if you need to scale beyond single server.
- throw14082020 2y agoAhhh, this sounds familiar! https://www.youtube.com/watch?v=b2F-DItXtZs https://www.youtube.com/watch?v=b2F-DItXtZs
- riku_iki 2y agothings still can be true, even if being wrapped into meme videos by haters..
- itake 2y agoPostgres has replicas? Most people use those for reads and a master writes.
- Tostino 2y agoThis can take you really damn far. I've been playing with CloudNativePG recently and adding replicas is easy as can be, they automatically sync up and join the cluster without you thinking about it. Way nicer than the bare-vm ansible setup I used at my last company.
- threeseed 2y agoHigh availability is more important than scalability for most. On average an AWS availability zone tends to suffer at least one failure a year. Some are disclosed. Many are not. And so that database you are running on a single instance will die. Question is do you want to do something about it or just suffer the outage.
- riku_iki 2y agoI think major providers provide PG service with cross zone availability through replication.
- threeseed 2y agoa) MongoDB has built-in, supported, proven scalability and high availability features. PostgreSQL does not. If it wasn't for cloud offerings like AWS Aurora providing them no company would even bother with PostgreSQL at all. It's 2025 these features are not-negotiable for most use cases. b) MongoDB does one thing well. JSON documents. If your domain model is built around that then nothing is faster. Seriously nothing. You can do tuple updates on complex structures at speeds that cripple PostgreSQL in seconds. c) Nobody who is architecting systems ever thinks this way. It is never MongoDB or PostgreSQL. They specialise in different things and have different strengths. It is far more common to see both deployed.
- jeremycarter 2y agoGreat response. All arguments are valid and fair.
- scosman 2y agoA) Postgres easily scales to billions of rows without breaking a sweat. After that shard. It’s definitely negotiable.
- threeseed 2y agoSo does a text file. Statements like yours are meaningless when you aren't specific about the operations, schema, access patterns etc. If you have a single server, relational use case then PostgreSQL is great. But like all technology it's not great at everything.
- scosman 2y agoThe use a text file. In all seriousness, calling Postgres’ scalability “not-negotiable for most use cases” is wild.
- threeseed 2y agoWhat's wild is you misrepresenting what I said which was: "built-in, supported, proven scalability and high availability" PostgreSQL does not have any of this. It's only good for a single server instance which isn't really enough in a cloud world where instances are largely ephemeral.
- beAbU 2y agoMongo is Web scale.
- leowoo91 2y agoinstagram use postgresql and still web-scale (unless this was satire)
- terafo 2y agohttps://www.youtube.com/watch?v=b2F-DItXtZs https://www.youtube.com/watch?v=b2F-DItXtZs
- plasma_beam 2y agoI have not watched that video since 2013 (wow!) and it is still hilarious.
- riku_iki 2y agothey obviously didn't use vanilla postgres, but built some custom sharding on top, which is untrivial task (implementation and maintenance(resharding, failover, replication, etc)).
- koakuma-chan 2y agoChoose Mongo if you need web scale.
- rudolph9 2y agoDon’t choose Mongo. It does everything and nothing well. It’s a weird bastard of a database—easily adopted, yet hard to get rid of. One day, you look in the mirror and ask yourself: why am I forking over hundreds of thousands of dollars for tens of thousands' worth of compute and storage to a company with a great business operation but a terrible engineering operation, continually weighed down by the unachievable business requirement of being everything to everyone?
- g7r 2y agoI have experience using both MongoDB and PostgreSQL. While pretty much spoken here is true, there is one more scalability aspect. When a fast moving team builds its service, it tends to not care about scalability. And in PostgreSQL there are much much more features that prevent future scalability. It's so easy to use them when your DB cluster is young and small. It's so easy to wire them up into the service's DNA. In MongoDB the situation is different. You have to deal with the bare minimum of a database. But in return your data design has much higher horizontal scalability survivability. In the initial phase of your startup, choose MongoDB. It's easier to start and evolve in earlier stages. And later on, if you feel the need and have resources to scale PostgreSQL, move your data there.