Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Speeding up query
Message
 
To
07/11/2002 14:33:24
Jerry Tovar
Dana Corporation Dana It
Maumee, Ohio, United States
General information
Forum:
ASP.NET
Category:
ADO.NET
Miscellaneous
Thread ID:
00719885
Message ID:
00720017
Views:
12
One thing to keep in mind is that to take advantage of connection pooling, you must use the same connection string and credentials. Also, make sure you manually close your connection.

>Cathi,
>
>Thanks for the response. So does that mean that the first time I call this function, the query could take a few seconds, but all the other calls would be fast?
>
>What I have done is place this function in a class library and call it from my application. Right now I test this query from a form that calls this class's function. But everytime I hit the button, the below code runs and the query always takes the same amount of time.
>
>If it ran slow the first time but ran fast after that, that would be OK. But it runs slow everytime.
>
>Or should I be using a different technique?
>
>Thanks,
>
>Jerry
>
>
>
>
>>Jerry,
>>
>>This is because of connection pooling. First time you run your application, it has to create the pool using the default settings or customized settings if specified in connection string. That incures an overhead, however for subsequent runs, the application just pulls one of the already opened connections, hence it is faster.
>>
>>You can usually speed the connection time by adding an entry to your hosts file mapping the server name to IP address. This does create a bit of a maintenance problem, but it shaves time off new connection creation. Of course if your servers don't have static IP addresses you won't be able to implement this.
>>
>>>I have created a C# form to access a VFP table on our network. The following is the code I am using to query this table. Everything works but the speed isn't that good. It takes about 2 seconds to return the result. The same query in VFP is immediate.
>>>
>>>The oConn.Open(); and the oDataAdapter.Fill(oDataSet,"MyTable"); seem to take the longest to execute. Is there anything I can do to speed up this query? Or a different way to do this?
>>>
>>>
>>>
>>>string strAccessConn = "Provider=VFPOLEDB.1;Data " +
>>>"Source=P:\\Mydir\\;Mode=ReadWrite|Share Deny None;Extended " +
>>>"Properties=\"\";User ID=\"\";Password=\"\";Mask Password=False;Cache " +
>>>"Authentication=False;Encrypt Password=False;Collating Sequence=MACHINE;DSN=\"\"";
>>>
>>>string strAccessSelect = "SELECT * FROM MyTable WHERE MyField = '" + lcMyVar + "'";
>>>
>>>DataSet oDataSet = new DataSet();
>>>oDataSet.Tables.Add("MyTable");
>>>
>>>OleDbConnection oConn = new OleDbConnection(strAccessConn);
>>>OleDbCommand oAccessCommand = new OleDbCommand(strAccessSelect,oConn);
>>>OleDbDataAdapter oDataAdapter = new OleDbDataAdapter(oAccessCommand);
>>>
>>>oConn.Open();   //Slow here.
>>>oDataAdapter.Fill(oDataSet,"MyTable"); //Slow here.
>>>
>>>
>>>
>>>Thanks,
>>>
>>>Jerry
-----------------------------------------

Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.com
www.prenia.com
Weblog: blogs.prenia.com/cathi
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform