确定用户在SQL Server中缓存的内存量

时间:2015-11-12 10:28:41

标签: sql-server caching sql-server-2014

我有一个包含多个用户的数据库。我需要处理缓存问题。

是否可以检查哪些用户缓存了最多的数据?

我知道这不会解决我的问题,但这是我需要的信息。

我知道可以检查哪个对象使用了多少内存缓存。但我希望获得有关用户的信息。

2 个答案:

答案 0 :(得分:0)

You can get information about amount of memory, used by the queries of a user in point of time, from DMV sys.dm_exec_sessions from column memory_usage

memory_usage / int / Number of 8-KB pages of memory used by this session. Is not nullable.

SELECT des.login_name
    ,SUM(memory_usage)*8 memory_usage_KB
FROM  sys.dm_exec_sessions des
WHERE des.is_user_process = 1
GROUP BY des.login_name

EDITED

Cached pages in buffer pool (and also execution plans in procedure cache) don't belong to any user, because they stay in there after completion of the query, that read this pages from disk into RAM, and they reused by other queries, which can belong to other sessions of many users.

答案 1 :(得分:0)

不可能,因为缓冲池(缓存数据),过程缓存(执行计划),内存分配和用户(会话)之间没有相关性。

如果您遇到性能问题,我建议您这样做并进行适当的调查。 How to analyse SQL Server performance是一个好的开始。特别是对于内存问题,您可以阅读Monitor Memory Usage,但您应首先证明内存使用是一个问题。

一般建议不要通过将问题描述为“存在问题”来接近专家。准确描述问题,症状,您遇到的任何错误信息,您做了哪些准确的调查,您测量的方式和内容以及观察到的值。