MongoDB indexed performance: ascending vs descending

Viewed 22

I'm trying to figure out if there is any performance issue when choosing ascending vs descending index:

I have the following index: <system_id, created>:

system_id: this is an ObjectId, ascending order.

created: this is a Date, ascending order.

My collection has more than 30 million documents.

I want to get the last documents which were created in the last week (created field) and belong to a certain system_id.

I'm limiting the results to 2000 documents and sorting them by created: -1.

The query takes a long time (more than a minute).

If I change the index to be system_id (asc), created (desc), will it be better in terms of performance?

0 Answers
Related