Home  /  Questions  /  Question



50   50
Jan 28, 2016


reducing sql connections & connection pools

Hi,
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



50   50
Feb 19, 2016
Thanks 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

0   0
Feb 18, 2016
If 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);
I Hope it helps. Regards
 

0   0
Jan 29, 2016
I didn't understand your question - "What is the philosophy with connection pools in do factory"

Thanks.

508   99.9
Jan 29, 2016
Connection 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