Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-25830

$comment on an empty query causes a collection scan

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Critical - P2 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

      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@mongodb.com Max Hirschhorn
            Reporter:
            genixpro Bradley Arsenault
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: