Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12141

MongoDB partial index optimization

$
0
0

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?


Viewing all articles
Browse latest Browse all 12141

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>