I have a MongoDB collection and the following query:
{ isActive: true, managerId: null, clientId: { $ne: null }}
I would like to optimize this query by creating an index. It looks like partial index would be a good solution:
createIndex( { /** @todo: specify keys */ }, { partialFilterExpression: { isActive: true, managerId: null, clientId: { $type: 'string', } } })
Now I know what to put in the partialFilterExpression
, but I don't quite figure out what fields should I put in the "keys" property.
My query has a fixed constant values everywhere, there is no variable parameters.
What would be the most optimal index for this kind of query?