Hi I created indexes on collection using this
First:
db.device_data.createIndex({'device_id': 1});
Second:
db.device_data.createIndex({'device_id': 1,'slave_id':1});
Now when I do db.device_data.getIndexes() I get these
{
"v": 2,
"key": {
"_id": 1
},
"name": "_id_",
"ns": "node-rest-auth-2.device_data"
}, {
"v": 2,
"key": {
"device_id": 1,
"slave_id": 1
},
"name": "device_id_1_site_id_1_slave_id_1",
"ns": "node-rest-auth-2.device_data",
"background": true
}, {
"v": 2,
"key": {
"device_id": 1
},
"name": "device_id_1",
"ns": "node-rest-auth-2.device_data"
}
Can someone explain the second and third key objects. How is single index of device_id different from the index that has both device_id and slave_id.
Update Use Case
I have a total of 300,000 documents in a collection and I am trying to fetch 30,000 at one go. Without any index (except for _id), using MEAN stack it takes 20s, upon indexing I was expecting some speed up but there was no significant change.