Connecting to Oracle is slow on ADO.NET under Vista
Our application uses the “System.Data.OracleClient” library to connect to our Oracle database. Something like this:
OracleConnection connection = new OracleConnection( "Data Source=prod8a;User Id=bugnav;Password=bugnav"); DateTime startTime = DateTime.Now; connection.Open(); Console.WriteLine(DateTime.Now - startTime);
Normally code like this would connect to Oracle in WELL under one second. However, under Vista, the first time I run this it takes 12 seconds! Subsequent executions are sub-second but, if I wait 60 seconds, the following connections are back up to 12 seconds. Very odd!
It turns out that I see this behaviour if connection pooling is enabled (and it is my default) or if the “Min Pool Size” is not specified in the connection string. The following two snippets work perfectly.
OracleConnection connection = new OracleConnection( "Data Source=prod8a;User Id=bugnav;Password=bugnav;Pooling=false"); DateTime startTime = DateTime.Now; connection.Open(); Console.WriteLine(DateTime.Now - startTime);
OracleConnection connection = new OracleConnection( "Data Source=prod8a;User Id=bugnav;Password=bugnav;Min Pool Size=10"); DateTime startTime = DateTime.Now; connection.Open(); Console.WriteLine(DateTime.Now - startTime);
I have no idea why this is happening but at least it`s easy enough to work around.
