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

Regex query performance regression in v2.6.0-rc0

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

      See QA-401.

      Show
      See QA-401.

      The following regex query takes roughly 8x longer in v2.6.0-rc0 vs. v2.4.9:

      db.QA401.find({ _id: /Big(ww)i/ }).sort({a:1})
      

      The test collection has 920 documents (see attached) with the following indices:

      db.QA401.ensureIndex({a:-1})
      db.QA401.ensureIndex({'a.a':-1})
      db.QA401.ensureIndex({'a.a.a':-1})
      

      v2.6.0-rc0:

      > db.QA401.find({ _id: /Big(ww)i/ }).sort({a:1}).explain();
      {
              "cursor" : "BtreeCursor _id_",
              "isMultiKey" : false,
              "n" : 0,
              "nscannedObjects" : 0,
              "nscanned" : 1,
              "nscannedObjectsAllPlans" : 1,
              "nscannedAllPlans" : 2,
              "scanAndOrder" : true,
              "indexOnly" : false,
              "nYields" : 0,
              "nChunkSkips" : 0,
              "millis" : 0,
              "indexBounds" : {
                      "_id" : [
                              [
                                      "",
                                      {
      
                                      }
                              ],
                              [
                                      /Big(ww)i/,
                                      /Big(ww)i/
                              ]
                      ]
              },
              "server" : "zzyzx:27017",
              "filterSet" : false
      }
      

      v2.4.9:

      > db.QA401.find({ _id: /Big(ww)i/ }).sort({a:1}).explain();
      {
              "cursor" : "BtreeCursor _id_ multi",
              "isMultiKey" : false,
              "n" : 0,
              "nscannedObjects" : 0,
              "nscanned" : 1,
              "nscannedObjectsAllPlans" : 0,
              "nscannedAllPlans" : 3,
              "scanAndOrder" : true,
              "indexOnly" : false,
              "nYields" : 0,
              "nChunkSkips" : 0,
              "millis" : 0,
              "indexBounds" : {
                      "_id" : [
                              [
                                      "",
                                      {
      
                                      }
                              ],
                              [
                                      /Big(ww)i/,
                                      /Big(ww)i/
                              ]
                      ]
              },
              "server" : "zzyzx:27018"
      }
      

      The query times are sub-millisecond; here is the output from QA-401:

      {
              "_id" : ObjectId("530f6bad7e6c53525919dfb6"),
              "deltaRatio" : "8.40",
              "deltaUs" : 741,
              "v249Avg" : "100.17",
              "v249Results" : [
                      100,
                      102,
                      101,
                      99,
                      100,
                      99
              ],
              "rc0Avg" : "841.17",
              "rc0Results" : [
                      870,
                      882,
                      839,
                      817,
                      815,
                      824
              ],
              "testId" : "GeneratedTests::GeneratedQuery750[Descending]",
              "qry" : "{ query: { _id: //Big(ww)i// }, orderby: { a: 1 } }",
              "proj" : "{ NONE: 1 }",
              "idx" : "Descending",
              "rc0Count" : 0,
              "v249Count" : 0,
              "countsMatch" : true
      }
      

      I'm having a tough time distilling this down to something which can be reproduced in the shell (with measurable results).

        1. QA401.export
          120 kB
        2. SERVER12952.cpp
          169 kB
        3. SERVER-12952-master-with-patches.svg
          106 kB
        4. SERVER12952-v249.svg
          99 kB

            Assignee:
            benety.goh@mongodb.com Benety Goh
            Reporter:
            benjamin.becker Ben Becker
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: