$comment on an empty query causes a collection scan

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Duplicate
    • Priority: Critical - P2
    • None
    • Affects Version/s: 2.6.11
    • Component/s: None
    • None
    • ALL
    • Hide

      create a huge database
      db.your_collection.count({$comment: "your_mom"});

      Wait patiently

      Show
      create a huge database db.your_collection.count({$comment: "your_mom"}); Wait patiently
    • None
    • 0
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Take a look at this operation:

      		{
      			"opid" : 1453296,
      			"active" : true,
      			"secs_running" : 238,
      			"microsecs_running" : NumberLong(238006204),
      			"op" : "query",
      			"ns" : "sensibill_loadtest.receipts",
      			"query" : {
      				"count" : "receipts",
      				"query" : {
      					"$comment" : {
      						"source" : "admin.js:383",
      						"version" : "d369cd29ba35"
      					}
      				},
      				"fields" : null
      			},
      			"planSummary" : "COLLSCAN",
      			"client" : "10.114.185.210:42439",
      			"desc" : "conn155298",
      			"threadId" : "0x7ebd51d57700",
      			"connectionId" : 155298,
      			"waitingForLock" : false,
      			"numYields" : 95285,
      			"lockStats" : {
      				"timeLockedMicros" : {
      					"r" : NumberLong(275342977),
      					"w" : NumberLong(0)
      				},
      				"timeAcquiringMicros" : {
      					"r" : NumberLong(641132),
      					"w" : NumberLong(0)
      				}
      			}
      		},
      

      We have code that adds a $comment to every query that we send to Mongo, so that we can track where it came from within our system.

      Normally it does not change results. However, on this empty receipts.count() query, it triggers a collection scan. Arggghhh!

            Assignee:
            Max Hirschhorn
            Reporter:
            Bradley Arsenault
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: