When comparing MongoDB vs Postgres, the Slant community recommends Postgres for most people. In the question“What are the best ACID-compliant scalable databases?” Postgres is ranked 1st while MongoDB is ranked 8th. The most important reason people chose Postgres is:
Built by passionate developers, available for free, and is well supported by its active community.
Specs
Ranked in these QuestionsQuestion Ranking
Pros
Pro Perfect documentation and tutorials
Miles above other databases in educational resources.
Pro Great speed
MongoDB queries can be very fast because the data is usually all in one place and can easily be retrieved in a single lookup. But this is true only when the data is truly a document. When it's trying to emulate a relational model it starts to become really slow because it may have to perform many independent queries to retrieve a single document.
Pro Uses JSON
As Node.js uses JavaScript there's no need to map the returned JSON data from MongoDB, as JavaScript is a superset of JSON. Essentially solving object-relational impedance mismatch by its very nature. Working with JSON is also easier overall as it more easily fits into how you would represent data on the client.
Pro Doesn't require a unified data structure
Mongo is very flexible in that it doesn't require a unified data structure across all objects. So it's rather easy to use.
Pro Easy to scale
MongoDB has powerful sharding and scaling capabilities for when the data stored in the database gets so large that a single machine may not be able to store all of it. Sharding solves this problem through horizontal scaling. Mongo gives developers the ability to easily and painlessly add or remove as many machines as needed.
Pro Open Source
Built by passionate developers, available for free, and is well supported by its active community.
Pro Supports migration from other major proprietary and open source databases
With the extensive SQL support and migration tools, Postgres users are easily able to migrate their databases over to the Postgres database with little effort.
Pro JSON support
JSON support allows for Postgres to transfer data as raw text and without attributes and markup overhead. This will result in new levels of speed, efficiency and flexibility for developers.
Pro Highly scalable
Continues to work well under low or heavy loads in order to meet the users' need.
Pro Object-Oriented Database
You can reuse existing approved design table and extend its capability by inheritance. You can reuse ancestor method byy declaring new trigger for descendant but reuse ancestor trigger procedure. You can add, remove or override column constraint making it differ from its ancestor. Applying OOP with database design help me reuse, extend, and encapsulate business logic and end up a rapid design, and less errants. PostgreSQL is a powerful RDBMS while its OOP is sufficient for OOP modular design. Especially its Open Source ,and free.
Pro True ACID-compliance
Built in, so users won't have to worry about atomicity, consistency, isolation and the durability of the database.
Pro Multi-Version Concurrency Control (MVCC)
Postgres uses MVCC. For each user connected to the database the Postgres database shows a snapshot of the database at a particular instance. When the database needs to update an item it will add the newer version and mark the old version as obsolete. This allows the database to save overhead but requires a regulated sweep to delete the old, obsolete data.
Pro Multiple Language Interfaces
"There are interfaces for Java (JDBC), ODBC, Perl, Python, Ruby, C, C++, PHP, Lisp, Scheme, and Qt just to name a few."
Pro Great query planner
Unlike MySQL, you generally don't spend time on hinting the query planner in order to make PostGres perform well.
Pro RETURNING option on INSERT queries
For example:
INSERT INTO table (field_1, field_2, field_3) VALUES (value_1, value_2, value_3) RETURNING id;
Cons
Con Reported to lose or corrupt data
MongoDB is famously known for leaking and losing data over time.
Con Document Stores may be not suited for relational data
MongoDB has no JOIN, all relations are supposed to be resolved client-size which entails additional requests to the server.
Con Need many search features
Though it is possible to index and search text in documents in MongoDB 4.0 in multiple languages. The indexing and search is not as powerful as for example Elastic Search. For instance not being able to search for only parts of words.
Con Overkill for simple setups
If a database will be doing many simple operations Postgres may be over-kill.