5 ms·
There are more and more relational databases that are beginning to accomplish what MongoDB is (sort of) doing. And ironically, doing it better. They all seem to
by chris_wot 11y ago
There are more and more relational databases that are beginning to accomplish what MongoDB is (sort of) doing. And ironically, doing it better. They all seem to use PostgreSQL (one that springs to mind is ToroDB).
I'm trying to understand why anyone would pick MongoDB over PostgreSQL these days?
- s_kilk 11y agoEh, Mongo still has a better distribution/sharding/failover story, which really matters for some.
- chris_wot 11y agoDoesn't ToroDB do this as a drop-in replacement though?
- e1ven 11y agoI didn't see anything about ToroDB dealing with sharding/replication on their site - It looked like it was only client protocol. If it can handle the replication elements, can you help me find a doc for that part?
- chris_wot 11y agoTry this presentation: http://www.slideshare.net/8kdata/torodb-scaling-postgresql-like-mongodb http://www.slideshare.net/8kdata/torodb-scaling-postgresql-l... Edit: does this help? ToroDB do certainly need to get better documentation :( https://github.com/torodb/torodb/wiki/Setting-up-ToroDB-as-hidden-slave-of-a-MongoDB-Replica-Set https://github.com/torodb/torodb/wiki/Setting-up-ToroDB-as-h...
- brandur 11y agoIt might be worth taking a look at Citus, which provides a roughly equivalent distribution and sharing story for Postgres. It's also recently been reworked as an extension and now available as open source [1] so that you can run it yourself. Also, speaking as someone who was an operator of a large Postgres DB and who is now an operator of a large Mongo DB, although Mongo has a nominal lead in this one area for the time being, by going to Mongo you sacrifice a lot (I really can't emphasize this point enough; the distribution/sharding story is really the only thing that Mongo is doing a better job of right now, Postgres is a clear winner in every other way). I'm really looking forward to (and hoping for) extensions like Citus becoming more mature so that optimal choice of database will be obvious under all circumstances. [1] https://www.citusdata.com/blog/17-ozgun-erdogan/403-citus-unforks-postgresql-goes-open-source https://www.citusdata.com/blog/17-ozgun-erdogan/403-citus-un...
- justinsb 11y agoIf you have an existing project that uses MongoDB, MongoDB has a lot of unusual behaviors that are difficult to reproduce (and not very well specified). Sorting on array values is tricky, for example. For new projects, I agree with you!
- chris_wot 11y agoThat sounds like a pretty good reason to migrate away from it!
- 153354 11y agoErr because things like this didn't even exist until 10 minutes ago and aren't production-ready. I don't really understand people who keep saying this. Postgresql supports JSON, but it doesn't have all of the code to go on top of it so that you can use it like mongo. As in, so you can do projects.find or projects.insert instead of a bunch of sql. Then there are all kinds of other issues related indexes and the differences between mongo and PostgreSQL and so on.
- rpedela 11y agoWhat are the issues with indexes? I would argue that JSON(b) support is now production ready in Postgres 9.5+. You can read, write, update, delete, and it is fast.
- 153354 11y agoThere are different types of indexes that mongo supports within a document that are more complex than what PostgreSQL can do. Or at least that is what I remember last time I checked. I mean that this persons code is not production-ready. As in there is no chance it emulates all of the features of mongo or has been performance tested etc.
- chris_wot 11y agoIn PostgreSQL 9.4, GIN indexes were introduced to allow for indexing components of complex jsonb data types. So yeah, what else is the issue? http://www.postgresql.org/docs/9.4/static/datatype-json.html http://www.postgresql.org/docs/9.4/static/datatype-json.html
- CHY872 11y agoSo, I haven't used Mongo, but here's a list of things I found to be bad about jsonb (use case was a project where we need to be able to quickly aggregate over large numbers of items with small-cardinality metadata): 1. Can't sort using a GIN index. 2. Stats are shit with GIN indices - Postgres assumes that every filter has 100 matches, every array has 99 elements or something. Usually this works well, sometimes (specifically in my case) it's terrible. Specifically, it means that if you combine an aggregation over a GIN filter with an inner join, the performance will be awful because postgres picked a nested loop join for expected 100 results instead of a hash join for the actual 50,000. 3. This also means that additional expression indices you add basically aren't getting used, because it'll always appear better to the query planner to use the GIN index first. This includes things like sorting. 4. Because of how jsonb is implemented (basically arrays containing fields ordered by key alphabetical), we discovered that we were taking out more and more fields out of our jsonb field and placing them in other columns, which kinda missed the point of it (but was very good that we could do so, yay relational data model). 5. Sorting can become an epic chore if you don't have stuff like enum types etc, especially when you try to combine it with tsvectors. So, very happy with Postgres, but don't slam people who don't use Postgres because of insufficient json support - because Postgres' json support although excellent has quirks that will bite you with certain use cases. Very good, but not a panacea.