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

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Backlog
    • Major - P3
    • Resolution: Unresolved
    • 2.8.0-rc1
    • None
    • Querying
    • None
    • Query Optimization

    Description

      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?

      Attachments

        Issue Links

          Activity

            People

              backlog-query-optimization Backlog - Query Optimization
              rgpublic rgpublic
              Votes:
              5 Vote for this issue
              Watchers:
              17 Start watching this issue

              Dates

                Created:
                Updated: