Within the last few years, many companies have started to move from MongoDB to PostgreSQL, including the giant newspaper and online publication - The Guardian. The famous American question-and-answer platform Quora is also an example of companies that heavily use MySQL as a data-store instead of NoSQLs such as Cassandra, MongoDB or CouchDB. In this article, let’s examine why MySQL and PostgreSQL are more favorable than MongoDB over time.
1. Better structured management system. In case you plan to move to a mix of structured and unstructured data or if you think ACID (atomicity, consistency, isolation and durability) compliance will be important for your product in the future, PostgreSQL is a great option to choose. According to Adam D’Angelo, Quora Founder, relational databases is the “right” way to structure most of the data for most user-generated content sites like Quora. Adam pointed out the strength of these schemas allowing the data to persist in a typed manner across lots of new versions of the application as it's developed. They can serve as documentation and also prevent a lot of bugs.
2. Better performance. It’s a very common thought that one of the best things about NoSQL database management systems is its performance. However, it comes as a surprise for everyone when PostgreSQL beat MongoDB’s performance ratings on EnterpriseDB.com in 2014. In tests based on selecting, loading, and inserting complex document data to the tune of 50 million records, PostgreSQL was around twice as fast at data ingestion, 2.5x as fast at data selection, and 3x as fast at data inserts … all while consuming 25% less disk space. East Agile also had a good experience using PostgreSQL in our project working with CPDP - a publicly useful database of police misconduct allegations against the Chicago Police Department. In this project, our team optimized PostgreSQL queries and gained a 10x improvement in index time on ElasticSearch while maintaining the same responsiveness and functionality.
3. JSON support. PostgreSQL has data constraint and validation functions to ensure that JSON documents are more meaningful. PostgreSQL is much more concerned with standards compliance and extensibility, giving you the freedom on how to store data. It uses both dynamic and static schemas which allow you to use it for relational data and normalized form storage. This, on the other hand, is not the strength of MongoDB. Through the use of the JSON blob column types, The Guardians team were able to quickly move from MongoDB to PostgreSQL with zero downtime.
4. Third-party tools compatible. PostgreSQL database management systems possess strong support from third-party tools, both free and commercial. These third-party tools include extensions to improve many aspects. For example, ClusterControl provides impressive assistance at managing, monitoring, scaling SQL and NoSQL open-source databases. DB Data Difftective helps to make data comparison and synchronization more effective. If the purpose is to scale data to heavy workloads, pgBackRest backup and restore system is a nice option to consider.
To wrap up,
There’s a wide range of database management systems on the market. Each of them has their own strengths and weaknesses. The decision to use any of them should depend on your business model and business needs. Think carefully about what you need out of your database management system and also have in mind a broad picture of what you may need in the next few years. Not just in terms of storage but also in terms of what you want to do with your data.
“When you’re picking a data store, the most important thing to understand is where in your data — and where in its connections — the business value lies. If you don’t know yet, which is perfectly reasonable, then choose something that won’t paint you into a corner. Pushing arbitrary JSON into your database sounds flexible, but true flexibility is easily adding the features your business needs.
Make the valuable things easy.” - Sarah Mei
References
1. "Postgres vs. MongoDB for Storing JSON Data - Sisense." 19 Aug. 2019, https://www.sisense.com/blog/postgres-vs-mongodb-for-storing-json-data/. Accessed 28 Nov. 2019.
2. "Comparing Popular Database Management Systems | AltexSoft." 20 Jun. 2019, https://www.altexsoft.com/blog/business/comparing-database-management-systems-mysql-postgresql-mssql-server-mongodb-elasticsearch-and-others/. Accessed 28 Nov. 2019.