Use single index VS COMPOUND

Hello everyone … I apologize for my bad English, analyzing with “explain” the use of the indexes on mongo I get a strange thing. The query is made on a date type field and on this field there is a TTL type index. Then there is another COMPOUND type index formed by “date” + “string column”. The query that I launch has as a condition only a range of dates and what I see is that the index with only the date is NOT used but the COMPOUND one is taken. Why does he not prefer to use the index formed by the date alone, since the only condition in the query is the date?

Hi @Valerio_Burla

That’s interesting.

Could you include some screenshots?

Maybe showing this:

  • Defined indexes in collection (db.coll.getCollectionIndexes(), or a similar command)
  • Query performed using .explain()
2 Likes