Re: Regex performance regression induced by match-all code

From: "Joel Jacobson" <joel(at)compiler(dot)org>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Regex performance regression induced by match-all code
Date: 2021-05-03 19:31:27
Message-ID: fc07bb1e-b55b-49e3-a55d-bc47b5ac828c@www.fastmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, May 2, 2021, at 18:53, Tom Lane wrote:
> fix-exponential-cost-of-checkmatchall-2.patch

Successfully tested.

SELECT
is_match <> (subject ~ pattern),
captured IS DISTINCT FROM regexp_match(subject, pattern, flags),
COUNT(*)
FROM performance_test
GROUP BY 1,2
ORDER BY 1,2;
?column? | ?column? | count
----------+----------+---------
f | f | 3253889
(1 row)

Time: 94149.542 ms (01:34.150)
Time: 91565.305 ms (01:31.565)
Time: 91565.305 ms (01:31.565)

SELECT regexp_matches('', '(.|){20}','');
regexp_matches
----------------
{""}
(1 row)

Time: 0.541 ms

SELECT regexp_matches('', '(.|){25}','');
regexp_matches
----------------
{""}
(1 row)

Time: 0.724 ms

SELECT regexp_matches('', '(.|){27}','');
regexp_matches
----------------
{""}
(1 row)

Time: 0.782 ms

/Joel

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2021-05-03 19:37:24 Re: PG in container w/ pid namespace is init, process exits cause restart
Previous Message Alvaro Herrera 2021-05-03 19:25:53 Re: PG in container w/ pid namespace is init, process exits cause restart