I have collection called 'jobs' with a document :
{
"_id": "4bb131682d0682845098eabe",
"jobId": "1403610",
"refmdList": [
{
"_id": "4bb11af1f8d48284e0b2ef87",
"addrIdx": 1,
"type": "primary"
}
],
"status": "Created in J4",
}
And java code is used to find that job document using:
private DBCursor getRefMdCursor(String refId)
{
DB db = JDatabase.getDatabase();
BasicDBObject search = new BasicDBObject();
search.put("refmdList._id", refId);
DBCollection col = db.getCollection("jobs");
DBCursor cur = col.find(search);
return cur;
}
This is very slow and the refmdList._id is not indexed. Is the solution to index this array object field to speed it up or is there something problematic with the DBCursor code above?
DBCursor class is from mongodb/mongo-java-driver/3.4.3/mongo-java-driver-3.4.3.jar