如何检查SQL Server的当前池大小 [英] How to check current pool size of SQL Server

查看:108
本文介绍了如何检查SQL Server的当前池大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以检查SQL Server中的当前连接池大小?我不是在谈论最大连接池大小,而是当前的池大小。假设最大池大小为100,并且有49个连接处于打开状态,现在应该显示51个可用或49个消耗的连接。

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?

推荐答案

那么多这些东西似乎不在dmv的直接访问范围之内。我敢肯定,比我自己更了解情况的人可以为您提供更好的答案。

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.

这是我所能接近的。

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.

这篇关于如何检查SQL Server的当前池大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆