-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.5.4
-
Component/s: Querying
-
Environment:db.serverBuildInfo()
"version" : "2.5.5-pre-",
"gitVersion" : "04221630900335fc6ee0d9922edae9d29f02d66d",
-
ALL
Testing query plans for $elemMatch queries. (Want to validate that adhoc queries supported by the array of
{k: key, v: value}subdocuments still performs.
Generation of test data:
for (i=1; i<100000; i++) { searchTerms = []; for (j=1; j<=100 ; j++) { val = (i+j) % 10 searchTerms[j-1] = {k: j, v: val} } db.searchTest.insert({"payload": "document " + i, "searchTerms": searchTerms}); } db.searchTest.ensureIndex({"searchTerms.k": 1, "searchTerms.v": 1});
2.4.6 explain output:
> db.searchTest.find({searchTerms: {$elemMatch: {k:1, v: 7}}}).explain() { "cursor" : "BtreeCursor searchTerms.k_1_searchTerms.v_1", "isMultiKey" : true, "n" : 10000, "nscannedObjects" : 10000, "nscanned" : 10000, "nscannedObjectsAllPlans" : 10000, "nscannedAllPlans" : 10000, "scanAndOrder" : false, "indexOnly" : false, "nYields" : 0, "nChunkSkips" : 0, "millis" : 50, "indexBounds" : { "searchTerms.k" : [ [ 1, 1 ] ], "searchTerms.v" : [ [ 7, 7 ] ] }, "server" : "xxx:27018" }
2.5.5-pre explain output
> db.searchTest.find({searchTerms: {$elemMatch: {k:1, v: 7}}}).explain() { "cursor" : "BasicCursor", "n" : 10000, "nscannedObjects" : 99999, "nscanned" : 99999, "nscannedObjectsAllPlans" : 100099, "nscannedAllPlans" : 100099, "scanAndOrder" : false, "indexOnly" : false, "nYields" : 781, "nChunkSkips" : 0, "millis" : 1566, "server" : "xxx:27017" }
Original index creation and explain testing was done with index intersection enabled, but I have since restarted mongod without index intersection enabled and 2.5.5-pre still fails to use the index.