Wednesday 27 May 2015

Which database is best? ( Mongodb vs mysql vs postgres )

Comparison Between MongoDB, MySQL and Postgres

Its always been a great point of discussion, which database to use or which is best among MongoDB, MySQL and postgres. I have seen a lot of discussion regarding the same but yet there were no conclusion. I decided to gather the pros and cons of all these and write a clear summary so that one can easily decide which database to choose for their project.

Let's start with MongoDB which is a NoSQL database that is being used by many good industries. It has reduced the problem of scalability. It stores the data in json format hence it doesn't had a rigid structure like we have in a relational database. This enhances one feature of MongoDB that it is scalable.

Sometimes, one want to have the mechanism of transaction in the database. NoSQL doesn't support transaction but being relational datbases MySQL and postgres supports the transaction. So, if you want to have transaction facility than use either mysql or postgres.

Now talking about the speed, postgres have much better speed than MongoDB. So if you want to have a better speed than use postgres.

Locks is another mechanism that one may wants to have in our databases. Locks facility is better in postgres and MySQL as compare to MongoDB because postgres supports row level, column level, table level lock whereas the MongoDB locks its whole collection(table).

Postgres can store geo-spatial data (coordinates of locations) that increases its one more feature. The disk space required by the postgres is lesser than MongoDB.

Recently JSON data type is also added in PostgresSQL which has added a great point of attraction for postgres instead of MongoDB.

The Postgres seems to be more equipped with the features. It also has advanced query optimizer, on the other hand, MySQL doesn't have a query plan cache
Scaling postgres database might be difficult as compared to nosql but there are techniques available to which can help to scale postgres.

With the above arguments, it can be clearly figure out that postgres are better than MongoDB and MySQL but it also depends on the requirements for choosing the database. So one must keeps the requirement in mind to choose the correct database to solve the purpose.

Hybrid Data Cluster with Postgres, MongoDB and Hadoop

One solution for choosing the database could be Hybrid Data Cluster i.e. we can have recent data stored in postgres and as it becomes old we can start moving it to MongoDB then to Hadoop. This means we can have the oldest data residing on Hadoop on which we can perform complex analysis.

0 comments:

Post a Comment

 

Copyright @ 2013 Appychip.

Designed by Appychip & YouTube Channel