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

$comment on an empty query causes a collection scan

    XMLWordPrintableJSON

Details

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

    Description

      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!

      Attachments

        Activity

          People

            max.hirschhorn@mongodb.com Max Hirschhorn
            genixpro Bradley Arsenault
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: