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

RegEx query predicates using the | (vertical bar) character cannot use tight index bounds

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.8.0-rc1
    • Component/s: Querying
    • None
    • Query Optimization

      The mongodb regex parser cannot create accurate bounds to allow indexed lookups when the regex includes the "|" character. This was allowed previously, but could lead to incorrect results.

      Original Description
      I've got a database with 14 mio rows representing an imaginary "file system". There are (amongst others) the fields "type" (only "folder" or "file"), "folder" and "filename".

      I now try this:

      {
      type:'folder',
      folder:/^example1/
      }
      
      Very fast. No results - as expected. In fact, no rows even start with "example".
      
      I now try this:
      
      {
      type:'folder',
      folder:/^example2/
      }
      

      Very fast, too. No results again - as expected.

      Now, I try this:

      {
      type:'folder',
      folder:/^example(1|2)/
      }
      

      This query never returns. The whole database becomes horribly slow to the point of being unusable. I cannot even run any other queries. This used to work on 2.4.x. Why?

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            rgpublic rgpublic
            Votes:
            5 Vote for this issue
            Watchers:
            17 Start watching this issue

              Created:
              Updated: