Bug #37461 | Connection pooling | ||
---|---|---|---|
Submitted: | 17 Jun 2008 20:57 | Modified: | 17 Apr 2012 21:32 |
Reporter: | Poul Bak | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | Connector / NET Documentation | Severity: | S4 (Feature request) |
Version: | 5.2.2 | OS: | Any |
Assigned to: | Tony Bedford | CPU Architecture: | Any |
Tags: | pooling |
[17 Jun 2008 20:57]
Poul Bak
[17 Jun 2008 20:59]
Poul Bak
Help text
Attachment: Connection pooling.txt (text/plain), 1.43 KiB.
[17 Jun 2008 21:14]
Poul Bak
Now the short version: Make it clear that pooling is 'All or nothing' and describe the 'all' approach.
[4 Jul 2008 14:54]
MC Brown
Assigning to Tony
[3 Feb 2009 11:57]
Tony Bedford
I've reworded the text as follows and added to the manual. I would really like to add some example code to this. Does anyone have a simple example that could be included? 1.5.2. Using Connector/NET with Connection Pooling The Connector/NET supports connection pooling. This is enabled by default, but can be turned off via connection string options. See Section 1.3.3.3, “ConnectionString” for further information. Connection pooling works by keeping the native connection to the server live when the client disposes of a MySqlConnection. Subsequently, if a new MySqlConnection object is opened, it will be created from the connection pool, rather than creating a new native connection. This improves performance. To work as designed, it is best to let the connection pooling system manage all connections. You should not create a globally accessible instance of MySqlConnection and then manually open and close it. This interferes with the way the pooling works and can lead to unpredictable results or even exceptions. One approach that simplifies things is to avoid manually creating a MySqlConnection object. Instead use the overloaded methods that take a connection string as an argument. Using this approach, Connector/NET will automatically create, open, close and destroy connections, using the connection pooling system for best performance. Typed Datasets and the MembershipProvider and RoleProvider classes use this approach. Most classes that have methods that take a MySqlConnection as an argument, also have methods that take a connection string as an argument. This includes MySqlDataAdapter. Instead of manually creating MySqlCommand objects, you can use the static methods of the MySqlHelper class. These take a connection string as an argument, and they fully support connection pooling.
[17 Apr 2012 21:32]
John Russell
In my opinion, the updated wording is sufficient without an extensive code example. Closing the bug now.