- Published on
MongoDB Sharding .md file
- Authors
- Name
- Ganesh Negi
Sharding
Sharding helps you to improve the performance,scalability and availablity of database applications.
What is the composition of ObjectID ?
ObjectID is composed of a timestamp, client machine ID,client process ID, and a 3-byte incremented counter.
What are the indexes in MongoDB ?
Indexes in MongoDB improve query performance
It enables the database to quickly locate documents based on the indexed fields.
Code Blocks
db.collection.createIndex({ "age": 1 }); // age_1
db.collection.createdIndex({ "age" : 1, "gender" :1 }) // age_1_gender_1
Explanation:-
First one code will create age index and age: 1 means it will index with ascending order, if we write -1 then it will do it descending order
Second code will create mulitple index with age and gender