[SERVER-40150] count({$or: [{x: {$exists: false}}, {x: false}]}}) is extremely slow Created: 15/Mar/19 Updated: 18/Mar/19 Resolved: 18/Mar/19 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Peter | Assignee: | Eric Sedor |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Operating System: | ALL |
| Participants: |
| Description |
|
db.collection.count({$or: [{deleted: {$exists: false}}, \{deleted: false}]}}) is extremmely slow:
I do have the index on deleted and as I understand it is expected to work. But it is not working in mongodb 3.4.10 and mongodb still examins lots of documents.
I've tryed to google answer, but I failed to find solution. I've tryed sparse indes, but as I read documentation it is not supposed to work, so now I have ordinary index - db.accounts.ensureIndex({deleted:1}). Any hints are really appreciated.
|
| Comments |
| Comment by Eric Sedor [ 18/Mar/19 ] |
|
The behavior of count with respect to examining documents is described here. If you need further assistance devising a data model that allows you to count using contiguous key values, please post on the mongodb-user group or on Stack Overflow with the mongodb tag. |