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

Performance regression with $where queries

    • Query Execution
    • ALL
    • Hide
      db.t.insert({a:1});
      db.t.find({a:0, $where:'sleep(1000)'});
      

      Note that neither version actually executes the $where clause.

      Show
      db.t.insert({a:1}); db.t.find({a:0, $where: 'sleep(1000)' }); Note that neither version actually executes the $where clause.

      A $where query in v2.6rc0 always creates a V8Scope, even if other operators do not match. v2.4.9 doesn't create a scope unless other operators match.

      For some queries, this results in v2.6rc0 running slower by two orders of magnitude; e.g.:

      {
      	"_id" : ObjectId("530f6bad7e6c53525919dfa9"),
      	"deltaRatio" : "92.31",
      	"deltaUs" : 11094.5,
      	"v249Avg" : "121.50",
      	"v249Results" : [
      		121,
      		123,
      		122,
      		120,
      		121,
      		122
      	],
      	"rc0Avg" : "11216.00",
      	"rc0Results" : [
      		11398,
      		11187,
      		11164,
      		11220,
      		11181,
      		11146
      	],
      	"testId" : "GeneratedTests::GeneratedQuery761[Compound2]",
      	"qry" : "{ query: { arrayField: null, d: { $mod: [ 314159265, 314159215 ] }, $where: \"function myFunction() { return String(this.a || this.b || this.c || this.d).length > 9; }\", _id: //d?[A-E]*// }, orderby: { d: 1 } }",
      	"proj" : "{ b: 1, a: 1 }",
      	"idx" : "Compound2",
      	"rc0Count" : 0,
      	"v249Count" : 0,
      	"countsMatch" : true
      }
      

            Assignee:
            backlog-query-execution [DO NOT USE] Backlog - Query Execution
            Reporter:
            benjamin.becker Ben Becker
            Votes:
            0 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated: