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

The $exists operator fails if the field is not indexed when using --notablescan

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.6.0
    • Component/s: Querying
    • Labels:
      None
    • Major Change
    • ALL
    • Hide

      Start mongod without --notablescan and run the attached script, the output is below:

      MongoDB shell version: 2.6.0
      connecting to: test
      { "_id" : ObjectId("53453ea01a5e1a8ac3c64a8d"), "a" : 1 }
      { "_id" : ObjectId("53453ea01a5e1a8ac3c64a8e"), "a" : 2 }
      { "_id" : ObjectId("53453ea01a5e1a8ac3c64a8f"), "a" : 3 }
      { "_id" : ObjectId("53453ea01a5e1a8ac3c64a90"), "b" : 1 }
      { "_id" : ObjectId("53453ea01a5e1a8ac3c64a91"), "b" : 2 }
      { "_id" : ObjectId("53453ea01a5e1a8ac3c64a92"), "b" : 3 }
      

      Start mongod with --notablescan and run the attached script, the output is below:

      MongoDB shell version: 2.6.0
      connecting to: test
      { "_id" : ObjectId("53453eb5677ff00bb2c52786"), "a" : 1 }
      { "_id" : ObjectId("53453eb5677ff00bb2c52787"), "a" : 2 }
      { "_id" : ObjectId("53453eb5677ff00bb2c52788"), "a" : 3 }
      2014-04-09T13:36:05.429+0100 error: {
              "$err" : "Unable to execute query: error processing query: ns=test.exist
      swithoutindex limit=0 skip=0\nTree: b exists\nSort: {}\nProj: {}\n No query solu
      tions",
              "code" : 17007
      } at src/mongo/shell/query.js:131
      
      Show
      Start mongod without --notablescan and run the attached script, the output is below: MongoDB shell version: 2.6.0 connecting to: test { "_id" : ObjectId("53453ea01a5e1a8ac3c64a8d"), "a" : 1 } { "_id" : ObjectId("53453ea01a5e1a8ac3c64a8e"), "a" : 2 } { "_id" : ObjectId("53453ea01a5e1a8ac3c64a8f"), "a" : 3 } { "_id" : ObjectId("53453ea01a5e1a8ac3c64a90"), "b" : 1 } { "_id" : ObjectId("53453ea01a5e1a8ac3c64a91"), "b" : 2 } { "_id" : ObjectId("53453ea01a5e1a8ac3c64a92"), "b" : 3 } Start mongod with --notablescan and run the attached script, the output is below: MongoDB shell version: 2.6.0 connecting to: test { "_id" : ObjectId("53453eb5677ff00bb2c52786"), "a" : 1 } { "_id" : ObjectId("53453eb5677ff00bb2c52787"), "a" : 2 } { "_id" : ObjectId("53453eb5677ff00bb2c52788"), "a" : 3 } 2014-04-09T13:36:05.429+0100 error: { "$err" : "Unable to execute query: error processing query: ns=test.exist swithoutindex limit=0 skip=0\nTree: b exists\nSort: {}\nProj: {}\n No query solu tions", "code" : 17007 } at src/mongo/shell/query.js:131

      The $exists operator fails if the field that is being checked for existence is not indexed and --notablescan is set. This is logical but is different to the behaviour in 2.4.9. The error message doesn't mention that it's due to table scans being disabled.

      I noticed this after upgrading from 2.4.9 to 2.6.0.

        1. test.js
          0.4 kB

            Assignee:
            david.storch@mongodb.com David Storch
            Reporter:
            tjrobinson Tom Robinson
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: