4 ms·
If you think of your database as a loosely constrained document storage - then yes, postgres is worse than mongo. But, if you think of your database as a singl
by vasachi 9y ago
If you think of your database as a loosely constrained document storage - then yes, postgres is worse than mongo.
But, if you think of your database as a single source of truth, then I almost can't imagine any reason to use mongo[1]. Without ACID transactions it is your problem to enforce all those pesky constraints across your whole codebase and data storage. And that work is HARD.
For instance. I once had to implement a simple scheduling app. Basically, if worker A was scheduled to work from 2017-04-30T18:00:00 to 2017-04-30T18:30:00, then there can't be any overlapping schedule item for said worker. I guess you can do something like a two-phase commit with mongo, but I used a tsrange[1] and an exclusion constraint, and got everything almost for free.
[1] Well, AFAIK mongo has better sharding. For now :)
[2] https://www.postgresql.org/docs/9.6/static/rangetypes.html https://www.postgresql.org/docs/9.6/static/rangetypes.html
[3] https://www.postgresql.org/docs/9.0/static/ddl-constraints.html#DDL-CONSTRAINTS-EXCLUSION https://www.postgresql.org/docs/9.0/static/ddl-constraints.h...