Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check current pool size of SQL Server

Is there a way to check the current connection pool size in SQL Server? I am not talking about the max connection pool size, but the current pool size. Let's say the max pool size is 100 and there are 49 connections open, it should now show me either 51 available or perhaps 49 consumed.

So, is there such a query?

like image 720
Frank Martin Avatar asked Feb 16 '14 08:02

Frank Martin


People also ask

What is pool size in SQL Server?

A connection pool is created for each unique connection string. When a pool is created, multiple connection objects are created and added to the pool so that the minimum pool size requirement is satisfied. Connections are added to the pool as needed, up to the maximum pool size specified (100 is the default).

How do I check my connection pool?

From the JDBC Connection Pool—>Monitoring tab, you can view information about the state of each deployed instance of the selected connection pool. That is, for each server on which the connection pool is deployed, you can see current status information about the connection pool.


1 Answers

So much of this stuff seems to be outside of what is directly accessible from dmv's. I'm sure someone more informed than myself can get you better answers.

This is as close as I could get.

SELECT  des.program_name
      , des.login_name
      , des.host_name
      , COUNT(des.session_id) [Connections]
FROM    sys.dm_exec_sessions des
INNER JOIN sys.dm_exec_connections DEC
        ON des.session_id = DEC.session_id
WHERE   des.is_user_process = 1
        AND des.status != 'running'
GROUP BY des.program_name
      , des.login_name
      , des.host_name
HAVING  COUNT(des.session_id) > 2
ORDER BY COUNT(des.session_id) DESC

This will aggregate your connections by login and from each host and app. This will give you an idea of how your connections are currently being pooled. If you know your max amount off hand, you can subtract the connections from it and it could give you the number of connections remaining in each pool.

like image 150
jwhaley58 Avatar answered Oct 10 '22 21:10

jwhaley58