Skip to Main Content

SQL & PL/SQL

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_SUBSTR , CONNECT BY slows down with value

jana KanagDec 3 2014 — edited Dec 4 2014

I have the following sql

SELECT distinct q.broker_ID, q.user_ID , q.MGC_BREACH_ALERT, REGEXP_SUBSTR (nvl(q.CGC_ALERT_THRESHOLDS,0),'[^|]+',1,LEVEL) value

FROM

(select u.broker_ID ,t.user_ID , t.CGC_ALERT_THRESHOLDS  ,t.MGC_BREACH_ALERT from ATSD_USE_TRADERS t ,ATS_USERS u where u.user_ID =t.user_ID and t.sponsored_user = 1) q

CONNECT BY  (REGEXP_SUBSTR (nvl(q.CGC_ALERT_THRESHOLDS,0),'[^|]+',1,LEVEL) IS NOT NULL)

order by 1

when all the values in the table has CGC_ALERT_THRESHOLDS as two pipe separated values (e.g  34|44) the query is running in less than 1 second.


When the CGC_ALERT_THRESHOLDS are three pipe separated values (e.g  34|44|54) then the query is taking more 30 seconds to complete.

The table has only about 150 rows .


Can anyone please explain where I have gone wrong / or any other suggested improvements to this query?

This post has been answered by Frank Kulash on Dec 3 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 31 2014
Added on Dec 3 2014
3 comments
1,438 views