Interview :: mongoDB
In MongoDB, Sharding is a procedure of storing data records across multiple machines. It is a MongoDB approach to meet the demands of data growth. It creates horizontal partition of data in a database or search engine. Each partition is referred as shard or database shard.
A replica can be specified as a group of mongo instances that host the same data set. In a replica set, one node is primary, and another is secondary. All data is replicated from primary to secondary nodes.
In MongoDB, primary nodes are the node that can accept write. These are also known as master nodes. The replication in MongoDB is single master so, only one node can accept write operations at a time.
Secondary nodes are known as slave nodes. These are read only nodes that replicate from the primary.
By default, MongoDB writes data only to the primary replica set.
MongoDB supports following CRUD operations:
- Create
- Read
- Update
- Delete
MongoDB uses BSON to represent document structures.
Yes. If you remove a document from database, MongoDB will remove it from disk too.
MongoDB doesn't follow file system fragmentation and pre allocates data files to reserve space while setting up the server. That's why MongoDB data files are large in size.
A storage engine is the part of a database that is used to manage how data is stored on disk.
For example: one storage engine might offer better performance for read-heavy workloads, and another might support a higher-throughput for write operations.
MMAPv1 and WiredTiger are two storage engine used by MongoDB.