161 points · by beardyw · 1y ago · 80 comments
I think the reason that a there are so many MongoDB wire compatible projects (like this postgres extension from microsoft, and ferretdb) is because people have systems that have MongoDB clients built into their storage layers but don't want to be running on MongoDB anymore, exactly because "performance, scale, and flexibility hit a wall".
If you can change the storage engine, but keep the wire protocol, it makes migrating off Mongo an awful lot cheaper.
MongoDB's protocol has fewer features (RIP easy synchronization and replication) but worse is better and if the "core" feature of a database it its query language, then the best/worst query language won, the simple, dumb, easy to replicate one.
For known attributes the model based on rigid tables having strict typing, with unknowns placed in one or more JSON fields works best for me. I mean for example there like 100 known attributes of a product, and the category-specific ones, the unknowns generated dynamically at runtime, go to the "product_attributes" JSON column.
You can do actual searches inside the JSON, index the table with JSONB contents etc. Things that became available in MongoDB very very late.
Going from 150ms to 8ms and 80% CPU reduction does not make any sense perf wise. I stand my point it's missing a lot of details in your post and probably miss usage.
Postgres has a good-enough (if not better) document DB inside it, but it also has a billion other features and widespread adoption. Mongo needs a huge benefit somewhere to justify using it.
Edit: on top of that, very few things that you store in the DB are non-relational. So you will always end up recreating a relational database on top of any NoSQL database. So why bother when you can just go for a RDBMS from the start?
Indeed, the tag line for one of the releases, I think 9.4 or 9.5, was “NoSQL on ACID”.
Though pretty sure Bruce is a teetotaler.
Hmm, interesting! I've been having some intermittent issues recently with a Postgres table that uses JSONB, where everything seems to lock up for several minutes at a time, with no useful logs as to why.
Do you have any more info about the GIN issue, and how it can be verified as being a problem please?
It’s not a super well-documented feature in postgres, so I also wound up doing some digging in the mailing lists, but I was really appreciative of all the detail in that GL issue and the associated links.
I think it illustrates the issue he's mentioning well enough.
> You can do actual searches inside the JSON, index the table
To be clear, you can do those things with Mongo (and the features have been available for a very long time), they just don't work as well, and are less reliable at scale.
Probably if someone looking to use jsonb to replace NoSQL DB would need to look deeper.
My team has compared PostgreSQL and MongoDB on analytical queries on JSON, and the results so far have been unimpressive: https://github.com/ClickHouse/JSONBench/
It's powerful, I love that it's there, but actually using it is always such a chore.
I think the biggest use case is big data and dev platform that need application compatibility and wrapping Atlas is less attractive for some reason.
And with things like this in the source https://github.com/microsoft/documentdb/blob/a0c44348fb473da...
I'd definitely stay away from it.
Looks like it supports background indexing too.
Date and Binary are ones I wish JSONB supported most often.
Selectivity is pretty hard to get right though so I can see why they stubbed it out and will deal with an actual implementation later.
That design allows arbitrary nested JSON data to be indexed using inverted indexes on top a variation of B-trees called Bw-trees, and seems like a nice way of indexing data automatically in a way that preserves the ability to do both exact and range matching on arbitrarily nested values.
Not sure if the query capabilities and syntax match azure docdb but the basic functionality should be workable.
GIN does not support range searches (needed for <, <=, >, >=), prefix or wildcard, etc. It also doesn't support index-only scans, last I checked. You cannot efficiently ORDER BY a nested GIN value.
I recommend reading the paper.
I think a `||` that works with JSON patches would be nice, but you can easily implement that as an extension if you need it.
Not the end of the world, but I have to look up the syntax every time I need to write a query.
I would prefer to use Postgres as my database, so this is worth investigating. Taking a brief look at the github page, it looks like it will be easy to swap it out in my code. So I think I know what I'll be spending my next sprint on.
The complexity of maintaining a relational database is at the core of their proprietary business model.
For operational systems, documents are just better in every way.
Leave the rdbms for analytics and reporting.
They (Microsoft) really don’t want you using it.
Cosmos can be a drop-in replacement.