Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Oledb connection pooling?
Message
De
06/03/2011 16:06:40
 
 
À
06/03/2011 12:23:50
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
VB 8.0
OS:
Vista
Network:
Windows XP
Database:
Jet/Access Engine
Application:
Desktop
Divers
Thread ID:
01502760
Message ID:
01502785
Vues:
45
>No. Which may be the flaw in my argument :-{
>
>I was just going to try it though. It seems as if pooling may not be enabled by default though it can be set in the data connection wizard or by adding 'OLE DB Services=-1' to the connection string. But that begs the question of why pooling is *not* the default....


It *does* seem strange that it's not the default ... I wonder what is the reasoning behind that?

~~Bonnie




>
>>And were you connecting with a JET provider?
>>
>>~~Bonnie
>>
>>
>>>>>>Check out the following tests
>>>>>>Testconnections2 returned 0.23 seconds, Testconnections3 returned 4.68 seconds, that's a factor of 20 slower. If there is any pooling done here, it's either not working for me, or it's kind of not very effective.
>>>>>>What am I missing?
>>>>>>
>>>>>>    Public Sub testConnections2()
>>>>>>        Dim cmd As New OleDbCommand
>>>>>>        Dim da As New OleDbDataAdapter(cmd)
>>>>>>        Dim conn As New OleDbConnection
>>>>>>        Dim dt As New DataTable
>>>>>>        conn.ConnectionString = My.Settings.b040_beConnectionString
>>>>>>        conn.Open()
>>>>>>        cmd.Connection = conn
>>>>>>        Dim n As Long
>>>>>>        Dim t As Date = Now
>>>>>>        For i As Integer = 1 To 100
>>>>>>            cmd.CommandText = "select Art_id from Artikel where Art_nr = '  125'"
>>>>>>            n = cmd.ExecuteScalar()
>>>>>>            cmd.CommandText = "select * from artikel where Art_Nr = '  125'"
>>>>>>            da.Fill(dt)
>>>>>>        Next
>>>>>>        Debug.Print((Now() - t).ToString)
>>>>>>    End Sub
>>>>>>    Public Sub testConnections3()
>>>>>>        Dim cmd As New OleDbCommand
>>>>>>        Dim da As New OleDbDataAdapter(cmd)
>>>>>>        Dim conn As New OleDbConnection
>>>>>>        Dim dt As New DataTable
>>>>>>        conn.ConnectionString = My.Settings.b040_beConnectionString
>>>>>>        cmd.Connection = conn
>>>>>>        Dim n As Long
>>>>>>        Dim t As Date = Now
>>>>>>        For i As Integer = 1 To 100
>>>>>>            conn.Open()
>>>>>>            cmd.CommandText = "select Art_id from Artikel where Art_nr = '  125'"
>>>>>>            n = cmd.ExecuteScalar()
>>>>>>            cmd.CommandText = "select * from artikel where Art_Nr = '  125'"
>>>>>>            da.Fill(dt)
>>>>>>            conn.Close()
>>>>>>        Next
>>>>>>        Debug.Print((Now() - t).ToString)
>>>>>>    End Sub
>>>>>>
>>>>>
>>>>>Look at it the other way:
>>>>>testConnection2 opened the connection once and took .23
>>>>>Assuming testConnection3 also took .23 the first time then the next 99 took only 4.45 i.e ~ .045 per connection = 5 times faster.
>>>>
>>>>
>>>>I think that if you take the code below out of the loop you'll have a better idea of the time conn.Open() takes after the first time
>>>>
>>>>testConnection2 = time to open once
>>>>testConnection3 = test to open a hundred times
>>>>
>>>>
>>>>>            cmd.CommandText = "select Art_id from Artikel where Art_nr = '  125'"
>>>>>            n = cmd.ExecuteScalar()
>>>>>            cmd.CommandText = "select * from artikel where Art_Nr = '  125'"
>>>>>            da.Fill(dt)
>>>>
>>>
>>>:-} :
System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(connectionString);
>>>
>>>           System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
>>>           sw.Start();
>>>           conn.Open();
>>>           conn.Close();
>>>           Console.WriteLine(sw.ElapsedTicks);
>>>           for (int x = 0 ; x <1000; x++)
>>>           {
>>>               conn.Open();
>>>               conn.Close();
>>>           }
>>>           Console.WriteLine(sw.ElapsedTicks);
1756136
>>>1919864
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform