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

Ranged regex uses inefficient indexBounds

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

      By querying using a ranged regex an additional indexBound is used with the part of the regex until the range begins.
      For example:

      db.coll.find({ _id: /^1541\/1\/F\/8\/1\/2014\/0[8-9]/ }).explain("executionStats")
      

      the indexBounds are:

      {
          "_id" : [ 
              "[\"1541/1/F/8/1/2014/0\", \"1541/1/F/8/1/2014/1\")", 
              "[/^1541\\/1\\/F\\/8\\/1\\/2014\\/0[8-9]/, /^1541\\/1\\/F\\/8\\/1\\/2014\\/0[8-9]/]"
          ]
      }
      

      This way it scans a lot more from the index. In this case the _id represents a date prefixed with other info. So the "additional" indexBound will scan all 01 to 09 months.

            Assignee:
            kelsey.schubert@mongodb.com Kelsey Schubert
            Reporter:
            mirceag Mircea Gaceanu
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: