r/PostgreSQL • • Jan 20 '24

Help Me! Doubt regarding PostgreSQL vs Mongodb

Why very often people say mongodb is not that better and we are being future proof to go with postgres? is there any condition that mongodb can't handle or such. I would love to get an answer that explains why actually why companies are shifting?

49 Upvotes

50 comments sorted by

View all comments

Show parent comment

1

u/BosonCollider Aug 11 '24

You can, but it's generally not a good idea to overuse json in a relational DB imho. Still a better idea than dealing with mongodb for anything multitenant though, document databases basically only work if a single teams applications handles all writes to it and turn into a nightmare otherwise.

They can be great for usecases where you just need to log a specific json response though, and they are great to store json-formatted logs until you know what to do with them. Though if you just need to store the json with no requirements to do advanced queries on it, postgres json columns tend to take up less space than mongo or elastic, and wide column databases or plain KV do the best when you have shallow keys instead of nested documents.