Bug #28167 Poor performance building connection string
Submitted: 30 Apr 2007 18:06 Modified: 3 May 2007 11:23
Reporter: Maxim Mass Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S5 (Performance)
Version:5.0.6 OS:Any
Assigned to: CPU Architecture:Any

[30 Apr 2007 18:06] Maxim Mass
Description:
Having a db call with 5.0.6 within a tight loop shows a significant performance hit dealing with building the connection string. Please take a look at the below profiler output that shows that far more time is spent building a connection (even though it should be pooled) than making the db call itself.

To summarize the attached profiler info, with 1148 calls taking a total of 58seconds, 11seconds was spent waiting on executereader but 40 seconds was spent in MySqlConnectionStringBuilder. This problem does NOT occur in 1.0.9!

How to repeat:
Put any db call in a tight loop and measure the performance with a profiling tool.

Suggested fix:
Try to cache the built connection string objects and ensure that it's not rebuilt unnecessarily.
[30 Apr 2007 18:07] Maxim Mass
profiler output

Attachment: mysql 5.0.6 .net connector performance.txt (text/plain), 11.31 KiB.

[2 May 2007 19:48] Maxim Mass
Patch to cache the ConnectionStringBuilder instances so they're not recreated

Attachment: ConnectionStringBuilderCaching.patch (application/octet-stream, text), 1.62 KiB.

[2 May 2007 20:54] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/25944
[2 May 2007 20:59] Reggie Burnett
Fixed in 5.0.7 and 5.1.1
[2 May 2007 21:00] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/25946
[3 May 2007 11:23] MC Brown
A note has been added to the 5.0.7 and 5.1.1 changelogs.