How to check current pool size of SQL Server

后端 未结 2 1757
情话喂你
情话喂你 2021-02-13 18:29

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 s

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-13 19:25

    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.

提交回复
热议问题