Re: [E] Regexp_replace bug / does not terminate on long strings

From: Miles Elam <miles(dot)elam(at)productops(dot)com>
To: pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: [E] Regexp_replace bug / does not terminate on long strings
Date: 2021-08-20 19:51:56
Message-ID: CAALojA-uQ+C_SOa2tfX3-sZypVZJJasxaOS2JLbgPDoGaMtFGQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Aug 20, 2021 at 12:32 PM Mark Dilger <mark(dot)dilger(at)enterprisedb(dot)com>
wrote:

>
> The following queries take radically different time to run:
>

Unbounded ranges seem like a problem. Seems worth trying a range from 1 to
N where you play around with N to find your optimum
performance/functionality tradeoff. {1,20} is like '+' but clamps at 20.

select regexp_replace(
repeat('someone,one,one,one,one,one,one,', 60),
'(?<=^|,)([^,]+)(?:,\1){1,20}(?=$|,)',
'\1', -- replacement
'g' -- apply globally (all matches)
);
- Miles Elam

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Mark Dilger 2021-08-20 20:26:37 Re: [E] Regexp_replace bug / does not terminate on long strings
Previous Message Mark Dilger 2021-08-20 19:32:26 Re: [E] Regexp_replace bug / does not terminate on long strings