Views: 9.3K
Replies: 4
Archived
|
reducing sql connections & connection poolsHi,
What is the philosophy with connection pools in do factory? It seems we make a connection on every query. Is there a way to use connection pools? Or is that a bad idea? Is this addressed in the SQL Database Pattern Framework? Thanks, Alan Alan Anderson, Jan 28, 2016
|
|
Reply 1Thanks for the answers guys. This helps me think this through a bit. From my understanding, connection pooling is happening in ADO.NET and since do factory is using ADO.Net, then it just magically happens for me. Does that sound right?
https://msdn.microsoft.com/en-us/library/8xx3tyca(v=vs.110).aspx Again, thanks for the answers. Alan Alan Anderson, Feb 19, 2016
|
|
Reply 2If i understand correctly your questions you can do something like this:
Create a list where you can store the connectios you have already created Then when you want to "create" a connection you can check the list (your pool) to see if there is already an existing connection and take it from there so you don't have to create a new one. If the connection does not exist add it to the list and that's how you can have you pool of connections and not create a new one each time you want to query the database. Example: [ThreadStatic] private static List<ConnectionSettings> PoolContext; var connectionSettings = PoolContext.Find(o => o.ProviderName == pConnectionSettings.ProviderName && o.ServerName == pConnectionSettings.ServerName && o.UserID == pConnectionSettings.UserID); Ramon Aguilar, Feb 18, 2016
|
|
Reply 3I didn't understand your question - "What is the philosophy with connection pools in do factory"
Thanks. Mukta Madankar, Jan 29, 2016
|
|
Reply 4Connection pooling is handled by the database drivers themselves.
You can configure this (on the connectionstring), but generally you should not have to change this.. Hope this helps. Jack Jack Poorte, Jan 29, 2016
|