mongodb covering index not working?
阿神
阿神 2017-05-02 09:26:38
0
1
771

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

阿神
阿神

闭关修行中......

reply all(1)
phpcn_u1582

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!

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template