Bug #101714 Critical performance issue
Submitted: 23 Nov 2020 6:59 Modified: 26 Jan 16:23
Reporter: Sergey Volkov Email Updates:
Status: Closed Impact on me:
Category:Connector / NET Severity:S5 (Performance)
Version:8.0.22, 8.0.23 OS:Any
Assigned to: CPU Architecture:Any

[23 Nov 2020 6:59] Sergey Volkov
Reading database is very slow.
After profiling it I found that 90% of all time is lost on regex ctor.
public IMySqlValue ReadColumnValue(int index, MySqlField field, IMySqlValue valObject)
Regex regex = new Regex("(?i)^[0-9A-F]{8}[-](?:[0-9A-F]{4}[-]){3}[0-9A-F]{12}$");

It is huge time loss on each value read.

How to repeat:
Any read with reader class.

Suggested fix:
This regex instance should be static, i.e. it will be constructed once.
[23 Nov 2020 7:02] Sergey Volkov

Attachment: 2020_11_20_13_21_30_forecast_calls.dtp_C_WINDOWS_SysWOW64_inetsrv_w3wp.exe_19.11.2020_12_20_28.png (image/png, text), 234.63 KiB.

[23 Nov 2020 14:37] Bradley Grainger
MySqlConnector (https://www.nuget.org/packages/MySqlConnector/) doesn't have this bug, and is optimised for performance (https://github.com/mysql-net/MySqlConnector/#performance); you may want to try it out as a workaround until this is fixed.
[30 Nov 2020 23:48] Matt Stubblefield
Another Profiler screenshot.

Attachment: 8.0.22-profiled.png (image/png, text), 191.85 KiB.

[30 Nov 2020 23:49] Matt Stubblefield
I profiled 8.0.22 vs 8.0.21 and can verify that it definitely appears to be the Regex constructor right around "ReadColumnValue".
[9 Dec 2020 16:16] MySQL Verification Team
https://bugs.mysql.com/bug.php?id=101739 marked as duplicate of this one.
[26 Jan 16:23] Christine Cole
Posted by developer:
Fixed as of the upcoming MySQL Connector/NET 8.0.24 release, and here's the proposed changelog entry from the documentation team:

Constructing a regular expression for each read diminished the performance
of Connector/NET. This fix limits the construction to one instance, which
now is reused.

Thank you for the bug report.
[15 Mar 5:14] MySQL Verification Team
Bug #102963 marked as duplicate of this one
[19 Apr 11:10] MySQL Verification Team
Bug #103305 marked as duplicate of this one.