I want to try to use mongodb covering index to improve query performance, but it cannot be achieved. The code is as follows
The picture below is the query statement
The index is as follows
Query Analysis
From the query analysis, we can see that mongodb still queries specific document information, and does not directly return data from the index
Help answer this question, please pay attention to the following situation:
1. What you created is a composite index: sale_amount+audit
2. In your composite index, there are two actual working indexes: sale_amount(prefix index) and sale_amount+audit
3. Corresponding to your query, you use audit as the condition {audit: true}, and the index will not be used.
For reference.
Love MongoDB! Have Fun!