Home » SQL & PL/SQL » SQL & PL/SQL » regexp_replace - too heavy? (Oracle 11g)
| regexp_replace - too heavy? [message #520916] |
Thu, 25 August 2011 07:32  |
 |
ecivgamer
Messages: 147 Registered: May 2011 Location: Ukraine
|
Senior Member |
|
|
I've got code for extracting numbers from varchar2 column:
with t1 as (
select 1 as acode, '100,00' as avalue from dual union all
select 2 as acode, '100.00' as avalue from dual union all
select 3 as acode, '100.00%' as avalue from dual union all
select 4 as acode, '100.00perc' as avalue from dual
)
select acode,
nvl(abs(regexp_replace(replace(avalue,',','.'),'[^1,2,3,4,5,6,7,8,9,0,.,]')),0) as avalue
from t1
After few weeks of using we received complain, the Customer said that "sometimes" the procedure works too long. He said, it always works about two minutes, but "sometimes" it can work more than 24 hours! He investigated the issue and decided that the problem is regexp_replace (it's too heavy).
Could you please:
1) explain to me is it true that regexp_replace is too heavy
2) give me solution how do I receive the same result without regexp_replace.
Actually, I'm not trying to prove that regexp_replace is normal. It's a pity, but I can't discuss the issue with the Customer. I'm just trying to understand details for myself.
[Updated on: Thu, 25 August 2011 08:01] by Moderator Report message to a moderator
|
|
|
|
|
|
|
|
|
|
| Re: regexp_replace - too heavy? [message #520928 is a reply to message #520926] |
Thu, 25 August 2011 08:22   |
cookiemonster
Messages: 13975 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
I'm with Joy. I don't believe for a second that the time difference described can be due to this function.
You need to trace the session when it's running slow to see what's really going on.
|
|
|
|
| Re: regexp_replace - too heavy? [message #520930 is a reply to message #520926] |
Thu, 25 August 2011 08:25  |
 |
Michel Cadot
Messages: 68773 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
First, a number should be in a number field.
If the format is always the one you gave you can do:
SQL> with t1 as (
2 select 1 as acode, '100,00' as avalue from dual union all
3 select 2 as acode, '100.00' as avalue from dual union all
4 select 3 as acode, '100.00%' as avalue from dual union all
5 select 4 as acode, '100.00perc' as avalue from dual
6 )
7 select acode,
8 nvl(to_number(translate(avalue,
9 ','||translate(avalue,'%.,0123456789','%'),
10 '.')),0) avalue
11 from t1
12 /
ACODE AVALUE
---------- ----------
1 100
2 100
3 100
4 100
Regards
Michel
|
|
|
|
Goto Forum:
Current Time: Thu Jan 01 17:45:29 CST 2026
|