Mongodb Overwrite Index Does Not Work?

  mongodb, question

I want to try to use mongodb to cover the index to improve the query performance, but it cannot be realized. The code is as follows
The following figure is a query statement
clipboard.png
The index is as follows

clipboard.png

Query analysis

clipboard.png

According to query analysis, mongodb still queries specific document information, instead of directly returning data by index

To help answer this question, please pay attention to the following situations:

1. What you created is a composite index: sale_amount+audit

2. in your composite index, there are two indexes for actual work: sales _ amount (prefix index) and sales _ amount+audit

3. Corresponding to your query, you use audit as the condition {audit: true} and will not use indexes.

For reference.

Love MongoDB! Have Fun!