Skip to content

Instantly share code, notes, and snippets.

@ixti
Created January 26, 2014 16:11
Show Gist options
  • Select an option

  • Save ixti/8635026 to your computer and use it in GitHub Desktop.

Select an option

Save ixti/8635026 to your computer and use it in GitHub Desktop.
MongoDB, are you serious???
% mongo
MongoDB shell version: 2.4.2
connecting to: test
> db.t1.ensureIndex({ username: 1 }, { sparse: true });
> db.t1.find({ deleted_at: { $exists: false }, username: "foo" }).explain()
{
"cursor" : "BasicCursor",
"isMultiKey" : false,
"n" : 0,
"nscannedObjects" : 3,
"nscanned" : 3,
"nscannedObjectsAllPlans" : 3,
"nscannedAllPlans" : 3,
"scanAndOrder" : false,
"indexOnly" : false,
"nYields" : 0,
"nChunkSkips" : 0,
"millis" : 1,
"indexBounds" : {
},
"server" : "silver:27017"
}
@stennie

stennie commented Jan 28, 2014

Copy link
Copy Markdown

FYI, a fix has been committed for this: https://jira.mongodb.org/browse/SERVER-10005. It will be in the next dev release (2.5.5) and 2.6 prod release. This issue was related to query optimiser changes for https://jira.mongodb.org/browse/SERVER-3918; the workaround is to "hint" as you are doing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment