PCRE2: zero-length assert lookahead slows quadratically for certain lengths

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Query Execution
    • ALL
    • QE 2025-09-15
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      This shows up in 8.0 and apparently not in 6.0 (PCRE2 was upgraded to in 6.1).

      Duration of this query relative to length of the string in the document being tested (when searched pattern does NOT occur in the string) where i is the length:

      db.coll.insert({string:'abc'.repeat(i)+'xxxxxxx'})
      db.coll.find({string:{$regex:"(?=.*arbitrary)"}})
      
      i duration (ms)
      1 1
      2 1
      4 1
      8 1
      16 1
      32 1
      64 2
      128 4
      256 12
      512 42
      1024 73
      2048 202
      4096 811
      8192 3243
      16384 13136
      32768 52250
      65536 210730
      131072 4
      262144 5
      524288 8

       

            Assignee:
            Ivan Fefer
            Reporter:
            Asya Kamsky
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: