页面除了已分配或已释放之外还可以是其他任何内容吗?

问题描述 投票:0回答:1

sp_WhoIsActive的文档指出

这些列中最令人困惑的是与 tempdb 相关的列。每列报告多个 8 KB 页面。 [tempdb_allocations] 列直接从 tempdb 相关的 DMV 中收集,并指示由于临时表、LOB 类型、假脱机或其他使用者而在 tempdb 中分配了多少页。 [tempdb_current] 列是通过从分配数量中减去 tempdb DMV 报告的已释放页面信息来计算的。看到大量分配和少量当前页面意味着您的查询可能会猛击 tempdb,但不会导致它增长。看到大量当前页面意味着您的查询可能是您注意到的所有自动增长的原因。

tempdb_current
是让我困惑的专栏。我的简单理解是,一页只能分配或释放,这意味着从一个数字中减去另一个数字不会产生任何帮助。显然,我错了。如果既没有分配也没有释放,页面会是什么样子?

sql sql-server t-sql allocation tempdb
1个回答
0
投票

数据来自这里

SELECT TOP(@i)
    tsu.session_id,
    tsu.request_id,
    tsu.user_objects_alloc_page_count +
        tsu.internal_objects_alloc_page_count AS tempdb_allocations,
    tsu.user_objects_alloc_page_count +
        tsu.internal_objects_alloc_page_count -
        tsu.user_objects_dealloc_page_count -
        tsu.internal_objects_dealloc_page_count AS tempdb_current
FROM sys.dm_db_task_space_usage AS tsu

sys.dm_db_task_space_usage

这用于会话的当前查询。如果查询已分配 1000 个页面并取消分配 800 个页面,则当前仍分配 200 个页面。

© www.soinside.com 2019 - 2024. All rights reserved.