4 ms·
Postgres 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:/
by SEJeff 2y ago
Postgres 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?
- winrid 2y agoWhen you write to a postgres jsonb field it updates the entire JSONB content, because that's how postgres's engine works. Mongo allows you to $set two fields on the same document at the same time, for example, and have both writes win, which is very useful and removes distributed locks etc. This is just like updating specific table columns on postgres, but postgres doesn't allow that within columns, you'd have to lock the row for updating to do this safely which is a PITA.