Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

REGEXP_COUNT in where slow

ThomasStrubAug 28 2018 — edited Aug 28 2018

Why is:

  select * from 
    ( with dat as (select level lv, rpad('X',500,'X') txt from dual connect by level <= 20000)
        select lv
             , REGEXP_COUNT(txt, '(ABC|DEF)([[:digit:]]){5}') as occurrences
        from   dat
      --where  REGEXP_COUNT(txt, '(ABC|DEF)([[:digit:]]){5}') > 1
     )
    where rownum > 1

0.019 seconds and

  select * from 
      ( with dat as (select level lv, rpad('X',500,'X') txt from dual connect by level <= 20000)
         select lv
              , REGEXP_COUNT(txt, '(ABC|DEF)([[:digit:]]){5}') as occurrences
        from  dat
         where REGEXP_COUNT(txt, '(ABC|DEF)([[:digit:]]){5}') > 1
      )
  where rownum > 1

6.7 seconds. Oracle computes the regexp_count in both executions. So there must be a difference in the evaluation is in the where part or not.

Best regards

Thomas

This post has been answered by Dom Brooks on Aug 28 2018
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 25 2018
Added on Aug 28 2018
3 comments
333 views