Remember that connections are combined into a connection string. If you have many databases and connect using many connections, your application will create a new connection if the correct connection string does not exist. Then it will merge this connection and, if the pool is full, hit the existing connection. By default, Max Pool Size is 100 connections, so if you regularly skip over more than 100 databases, you close and open connections all the time.
This is not ideal, but you can solve this problem by always connecting to the same database (one connection string), and then switch to the db context "USE [DBName]". There are disadvantages:
- You lose the ability to specify a user / password for each connection string (the user of your application requires permission for all databases).
- Your SQL is becoming more complex (especially if you use ready-made ORMs or stored procedures).
You can experiment with increasing the Max Pool Size if the number of your databases is not large. Otherwise, if some databases are often used and others not, you can disable them on infrequent dbs. Both elements are configured using connectionstring .
In terms of metrics, tracking SQL Server login and logout events is a good start. If your application blends well, you shouldn't see a lot of them.
Corbin March Nov 10 '08 at 23:26 2008-11-10 23:26
source share