great place to work

MongoDB and DocumentDB – The Functional Differences, Advantages and Comparison


MongoDB Vs DocumentDB

With the invention of newer technologies, some of the flaws of the traditional relational database scheme have become evident. If we consider Big Data Analytics then the sheer quantity and lack of structure make it difficult to implement it using RDBMS. This is where NoSQL steps in. NoSQL is an approach that incorporates several data models, such that it can handle all sorts of structured, semi-structured and unstructured data sets. There are several services that offer NoSQL such as DocumentDB, MongoDB, CouchDB etc.

In this blog post, we are going to talk about two in particular – DocumentDB and MongoDB.

MongoDB & DocumentDB – The Similarities

MongoDB and DocumentDB are two APIs which can be referred to as CosmosDB resource in Azure. Here, the data is stored in documents, which are then collected and they collectively form a database. There are some evident similarities and differences between both of them. The similarities are:

  • The format in which data is stored in the document is JSON or JSON like formats, such as BSON. Since JSON is a universally accepted format, this makes it easier to integrate it with other systems.
  • The documents can be easily queried and obtained using querying languages, that are similar to SQL.

Advantages of MongoDB

  • MongoDB has a feature called aggregation pipeline where multi-stage filtering can be implemented so that it can procure documents from a collection and provide a crisp, filtered output. DocumentDB can handle only simple SQL-like queries.
  • MongoDB provides us with full-text indexes, while DocumentDB doesn’t.
  • Another feature unique to MongoDB is the ‘map reduce’. The data from the collection is made to go through two stages that repeatedly filter it before projecting the output.
  • One major advantage that MongoDB has over DocumentDB is the fact that MongoDB is a service in its own, so it can easily be integrated with multiple platforms, unlike DocumentDB, which runs on Azure.

Advantages of DocumentDB

  • DocumentDB is basically designed to integrate server side Javascript functions into its working. Strictly speaking, MongoDB can handle some server side Javascript functions, but it is severely limited compared to that of DocumentDB.
  • A key feature of DocumentDB is that it can perform ACID functions, while MongoDB can only be atomic in each document. This is more of a disadvantage of MongoDB, rather than an advantage of DocumentDB.
  • When it comes to indexing, DocumentDB has a rather over-the-top approach. It fully indexes everything. This results into good performance. It should be mentioned, however, that it is possible to implement custom indexing policies, to provide better control over what is being indexed.
  • A very important feature of any NoSQL service is scaling, and DocumentDB makes it very easy to set up a world-wide cluster, with options for everything from consistency levels to configuring failovers for potential errors. Again, this is possible in MongoDB, but it is relatively limited and also, much harder.
  • DocumentDB, as a part of Azure, provides built-in security as well.

There are several factors to consider when selecting which NoSQL service to use for your purpose. If your task requires complex filtering from all the documents in the collections, then MongoDB with its aggregation pipelining and map-reduce features would be a better choice. If it can be implemented with simple SQL like queries, then maybe DocumentDB could handle your task. Also, if your task requires multi-document ACID transactions then DocumentDB should be selected. Not to mention, if server-side Javascript functions are required, then probably you should go for DocumentDB.

There are several advantages to each service, and proper research must be conducted so that a learned decision can be made.


Abraham Shelly, Software Engineer, RapidValue

Please Share Your Thoughts & Comments Below.

How can we help you?