Bug #106135 REGEXP performance failure
Submitted: 11 Jan 2022 15:33 Modified: 13 Jan 2022 14:49
Reporter: Александр Ммммммм Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S5 (Performance)
Version:8.0.27 OS:Any
Assigned to: CPU Architecture:Any

[11 Jan 2022 15:33] Александр Ммммммм
Description:
SELECT 'dasdasdasdasdaaaaaaasdaaaaaaaaaaaDDsda@gmail.com'
REGEXP '^[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'
AS check_email

1 row retrieved starting from 1 in 45 ms (execution: 11 ms, fetching: 34 ms)

SELECT 'dasdasdasdasdaaaaaaasdaaaaaaaaaaa; sda@gmail.com'
REGEXP '^[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'
AS check_email

1 row retrieved starting from 1 in 17 s 914 ms (execution: 17 s 893 ms, fetching: 21 ms)

'dasdasdasdasdaaaaaaasdaaaaaaaaaaaDDsda@gmail.com' - < 1мс
'dasdasdasdasdaaaaaaasdaaaaaaaaaaa; sda@gmail.com' - 17сек

breaks exactly "; " (semicolon + space) before @
just a semicolon - ok, just space - ok
each subsequent character before a comma and a space increases the execution time by 2 times

How to repeat:
(look above How to repeat)
[11 Jan 2022 15:51] MySQL Verification Team
Hello Александр Ммммммм,

Thank you for the report and feedback.

regards,
Umesh
[12 Jan 2022 7:22] Tor Didriksen
Posted by developer:
 
MySQL 8.0 uses ICU regexp, please see performance tips here:
https://unicode-org.github.io/icu/userguide/strings/regexp.html
[13 Jan 2022 14:20] Александр Ммммммм
Thanks, I solved problem. REGEXP works properly and well. I had a problem in escape dot.
REGEXP '\.' = REGEXP '.' - mean 1 any symbol
right syntax
REGEXP '\\.' - mean dot symbol
[13 Jan 2022 14:49] MySQL Verification Team
Thank you for confirming that your problem is solved.
Closing the issue for now if you have no issues.

regards,
Umesh