From: | Florian Pflug <fgp(at)phlo(dot)org> |
---|---|
To: | Craig Ringer <craig(at)2ndquadrant(dot)com> |
Cc: | Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Sandro Santilli <strk(at)keybit(dot)net> |
Subject: | Re: Uninterruptable regexp_replace in 9.3.1 ? |
Date: | 2014-02-21 16:04:04 |
Message-ID: | D4594E29-6A28-43C0-BD33-FC3EE8A23683@phlo.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs pgsql-hackers |
On Feb21, 2014, at 16:46 , Craig Ringer <craig(at)2ndquadrant(dot)com> wrote:
> The real question IMO is why it's taking so long. It looks like
> cfindloop(...) is being called multiple times, with each call taking a
> couple of seconds.
Yeah, I wondered about this too. I've shortened the example a bit - here
are a few observations
postgres=# select regexp_matches(' $a$b$c$',
$REG$((?:[^'"$;]+|"[^"]*"|'(?:[^']*|'')*'|(\$[^$]*\$).*\2)+)$REG$, 'g');
Time: 33.026 ms
postgres=# select regexp_matches(' $a$b$c$',
$REG$((?:[^'"$;]+|"[^"]*"|'(?:[^']*|'')*'|(\$[^$]*\$).*\2)+)$REG$, 'g');
Time: 60.594 ms
postgres=# select regexp_matches(' $a$b$c$',
$REG$((?:[^'"$;]+|"[^"]*"|'(?:[^']*|'')*'|(\$[^$]*\$).*\2)+)$REG$, 'g');
Time: 114.410 ms
postgres=# select regexp_matches(' $a$b$c$',
$REG$((?:[^'"$;]+|"[^"]*"|'(?:[^']*|'')*'|(\$[^$]*\$).*\2)+)$REG$, 'g');
Time: 227.467 ms
postgres=# select regexp_matches(' $a$b$c$',
$REG$((?:[^'"$;]+|"[^"]*"|'(?:[^']*|'')*'|(\$[^$]*\$).*\2)+)$REG$, 'g');
Time: 452.739 ms
postgres=# select regexp_matches(' $a$b$c$',
$REG$((?:[^'"$;]+|"[^"]*"|'(?:[^']*|'')*'|(\$[^$]*\$).*\2)+)$REG$, 'g');
Time: 943.098 ms
postgres=# select regexp_matches(' $a$b$c$d$e$',
$REG$((?:[^'"$;]+|"[^"]*"|'(?:[^']*|'')*'|(\$[^$]*\$).*\2)+)$REG$, 'g');
Time: 200.795 ms
postgres=# select regexp_matches(' $a$b$c$d$e$f$',
$REG$((?:[^'"$;]+|"[^"]*"|'(?:[^']*|'')*'|(\$[^$]*\$).*\2)+)$REG$, 'g');
Time: 298.264 ms
postgres=# select regexp_matches(' $a$b$c$d$e$f$g$',
$REG$((?:[^'"$;]+|"[^"]*"|'(?:[^']*|'')*'|(\$[^$]*\$).*\2)+)$REG$, 'g');
Time: 444.219 ms
postgres=# select regexp_matches(' $a$b$c$d$e$f$g$h$',
$REG$((?:[^'"$;]+|"[^"]*"|'(?:[^']*|'')*'|(\$[^$]*\$).*\2)+)$REG$, 'g');
Time: 696.137 ms
postgres=# select regexp_matches(' $a$b$c$d$e$f$g$h$i$',
$REG$((?:[^'"$;]+|"[^"]*"|'(?:[^']*|'')*'|(\$[^$]*\$).*\2)+)$REG$, 'g');
Time: 974.502 ms
postgres=# select regexp_matches(' $a$b$c$d$e$f$g$h$i$j$',
$REG$((?:[^'"$;]+|"[^"]*"|'(?:[^']*|'')*'|(\$[^$]*\$).*\2)+)$REG$, 'g');
Time: 1369.703 ms
postgres=# select regexp_matches(' $a$b$c$d$e$f$g$h$i$j$',
$REG$((?:[^'"$;]+|"[^"]*"|'(?:[^']*|'')*'|(\$[^$]*\$).*\2)+)$REG$, 'g');
Time: 2747.766 ms
In other words, the observes runtime is roughly 2^i * 1.5^j for inputs
consiting of i leading spaces (any character will probably do) followed
by j substring of the form $X$ (X is an arbitrary character).
best regards,
Florian Pflug
From | Date | Subject | |
---|---|---|---|
Next Message | slawek.slusarczyk | 2014-02-21 16:20:34 | BUG #9307: I can not install the binary version 9.3.3 under Windows 7 Ultimate |
Previous Message | Craig Ringer | 2014-02-21 15:46:45 | Re: Uninterruptable regexp_replace in 9.3.1 ? |
From | Date | Subject | |
---|---|---|---|
Next Message | Jeff Janes | 2014-02-21 16:08:16 | Re: Storing the password in .pgpass file in an encrypted format |
Previous Message | Christopher Browne | 2014-02-21 15:52:06 | Re: Storing the password in .pgpass file in an encrypted format |