MongoDB: counting slowly when using $ in

MongoDB 3.0.3

These two lines end in less than a second.

db.documents.count({'docType': 'fcsNotificationEF'});
db.documents.count({'docType': 'fcsNotificationZK'});

And it didn’t end in a minute

db.documents.count({'docType': {$in: ['fcsNotificationEF', 'fcsNotificationZK']}})

I have an index for docType. As I understand it, this line from the output db.currentOpconfirms that the index is being used:

"planSummary": "IXSCAN { docType: 1.0 }"

This workaround did not end in a minute.

+4
source share

Source: https://habr.com/ru/post/1598494/


All Articles