Bug #26152 Opening a connection is really slow
Submitted: 7 Feb 2007 17:20 Modified: 22 Feb 2007 10:19
Reporter: Paolo Niccolò Giubelli Email Updates:
Status: Closed Impact on me:
Category:Connector / NET Severity:S5 (Performance)
Version:5.0.3 OS:Windows (Windows Vista RC1)
Assigned to: CPU Architecture:Any
Tags: Connection, connector, slow

[7 Feb 2007 17:20] Paolo Niccolò Giubelli
The connection opening task is really slow using this version of the .net connector. The 1.0x version seems to be really faster.

How to repeat:
Simply write this code [C#]
MySqlConnection conn = new MySqlConnection("Server=;Database=xxx;Uid=xxx;Pwd=xx;");

Place a breakpoint on the .Open() line and one on the .Close() line, so you will be able to experience the ~5-6 seconds delay between them.
I tried the same program (on the same machine / server of course) using the 1.0.9 connector and it works good. My computer is an amd athlon x2 3800+.
[9 Feb 2007 9:49] Paolo Niccolò Giubelli
I noticed that the 'bug' is located into the method GetStream() (StreamCreator.cs) at line 73. I changed the statement:
IPHostEntry ipHE = Dns.GetHostEntry(dnsHosts[index]);
IPAddress addr = null;
IPHostEntry ipHE;
if (IPAddress.TryParse(dnsHosts[index], out addr))
 ipHE = new IPHostEntry();
 ipHE.AddressList = new IPAddress[1];
 ipHE.AddressList[0] = addr;
 ipHE = Dns.GetHostEntry(dnsHosts[index]);
and now it works good. I had also noticed that the original version works good  if I use the dns name instead of the ip address.
The 1.0.9 version is not affected by this problem because it invokes the deprecated method 'GetHostByName' that seems to work differently from the GetHostEntry() one. I hope this helps.
Paolo Niccolo' Giubelli
ITestense s.n.c.
[20 Feb 2007 20:49] 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:

[20 Feb 2007 20:49] Reggie Burnett
Fixed in 5.0.4
[22 Feb 2007 10:19] MC Brown
A note has been added to the 5.0.4 changelog.