I am looking to create an index on MongoDB, am relatively new to this type of DBMS, have looked in the MongoDB log and noticed that its doing a COLLSCAN which from reading online can indicate that an index would be more efficient.
This is the query:
{ find: "PaitemCode", filter: { trackRef: /^aut$/i, time: "1250", item.9.silk: /20210930aut1250/ }, limit: 1 }
We have the fields trackref, time, item but what would be the best way of putting an index in that would be efficient to this query?
{
"trackRef" : 1,
"time" : 1,
"item" : 1
}
Any help is much appreciated. Not sure of the implication of adding indexes in. I am using Robo3T to view the MongoDB DB via a GUI.
MongoDB Version is v3.4.24
explain
method).db.collection.createIndex( { "trackRef" : 1, "time" : 1, "item": 1 } )
and share the explain plan