Please find the schema of a mongodb document.
{
"_id" : ObjectId("000ac1da28d48426a46ba80b"),
"sentDate" : ISODate("2022-05-10T19:49:00Z"),
"rootId" : UUID("1623178c-9a7b-4e4f-a49c-6dda5cc4f47f"),
"vehicleId" : UUID("ff4fc2e9-9dae-4cb5-8834-c654fc39faa6"),
"serialNumber" : "AB00016987"
"points" : [{
"point" : {
"type" : "Point",
"coordinates" : [82.655769000000006, -17.650956999999998]
}
}]
}
A collection has few billions documents. We have to create an index to improve the read operation and have to be careful for write operation as well.
db.sampleData.createIndex( { rootId: 1, vehicleId: 1, sentDate: -1 } );
OR
db.sampleData.createIndex( { rootId: 1, serialNumber: 1, sentDate: -1 } );
Which index would be the best per MongoDB? Any suggestion on this.
Thanks much!