Features of MongoDB
The important MongoDB features High performance, Sharding, GridFS, Aggregation, Replication, Indexing, Document-Oriented, Schema-Less Database, and Ad-hoc Queries.
- Ad-hoc Queries
- Schema-Less Database
- High Performance
Generally, when we design a schema of a database, we don’t know in advance about the queries we will perform. Ad-hoc queries are the queries not known while structuring the database.
So, MongoDB provides ad-hoc query support which makes it so special in this case. Ad-hoc queries are updated in real time, leading to an improvement in performance.
In MongoDB, one collection holds different documents. It has no schema so can have many fields, content, and size different than another document in the same collection. This is why MongoDB shows flexibility in dealing with the databases.
MongoDB is a document-oriented database, which is a great feature itself. In the relational databases, there are tables and rows for arrangements of the data. Every row has specific no. of columns & those can store a specific type of data.
Here comes the flexibility of NoSQL where there are fields instead of tables and rows. There are different documents which can store different types of data. There are collections of similar documents. Each document has a unique key id or object id which can both be user or system defined.
Indexing is very important for improving the performances of search queries. When we continuously perform searches in a document, we should index those fields that match our search criteria.
In MongoDB, we can index any field indexed with primary and secondary indices. Making query searches faster, MongoDB indexing enhances the performance.
When it comes to redundancy, replication is the tool that MongoDB uses. This feature distributes data to multiple machines. It can have primary nodes and their one or more replica sets. Basically, replication makes ready for contingencies.
When the primary node is down for some reasons, the secondary node becomes primary for the instance. This saves our time for maintenance and makes operations smooth.
MongoDB has an aggregation framework for efficient usability. We can batch process data and get a single result even after performing different operations on the group data.
The aggregation pipeline, map-reduce function, and single purpose aggregation methods are the three ways to provide an aggregation framework. We will see them in detail in further articles.
GridFS is a feature of storing and retrieving files. For files larger than 16 MB this feature is very useful. GridFS divides a document in parts called chunks and stores them in a separate document. These chunks have a default size of 255kB except the last chunk.
When we query GridFS for a file, it assembles all the chunks as needed.
Basically, the concept of sharding comes when we need to deal with larger datasets. This huge data can cause some problems when a query comes for them. This feature helps to distribute this problematic data to multiple MongoDB instances.
The collections in the MongoDB which has a larger size are distributed in multiple collections. These collections are called “shards”. Shards are implemented by clusters.
MongoDB is an open source database with high performance. This shows high availability and scalability. It has faster query response because of indexing and replication. This makes it a better choice for big data and real-time applications.
Must Read About MongoDB Tutorial.