DMV to track the temp file usage for SQLServer
There are three DMVs you can use to track tempdb usage:
sys.dm_db_task_space_usage
sys.dm_db_session_space_usage
sys.dm_db_file_space_usage
The first two will allow you to track allocations at a query & session level. The third tracks allocations across version store, user and internal objects.
The following example query will give you allocations per session:
SELECT
s.session_id AS [SESSION ID]
,DB_NAME(database_id) AS [DATABASE Name]
,HOST_NAME AS [System Name]
,program_name AS [Program Name]
,login_name AS [USER Name]
,status
,cpu_time AS [CPU TIME (in milisec)]
,total_scheduled_time AS [Total Scheduled TIME (in milisec)]
,total_elapsed_time AS [Elapsed TIME (in milisec)]
,(memory_usage * 8) AS [Memory USAGE (in KB)]
,(user_objects_alloc_page_count * 8) AS [SPACE Allocated FOR USER Objects (in KB)]
,(user_objects_dealloc_page_count * 8) AS [SPACE Deallocated FOR USER Objects (in KB)]
,(internal_objects_alloc_page_count * 8) AS [SPACE Allocated FOR Internal Objects (in KB)]
,(internal_objects_dealloc_page_count * 8) AS [SPACE Deallocated FOR Internal Objects (in KB)]
,CASE is_user_process
WHEN 1 THEN 'user session'
WHEN 0 THEN 'system session'
END AS [SESSION Type],
s.row_count AS [ROW COUNT]
FROM sys.dm_db_session_space_usage su INNER join sys.dm_exec_sessions s ON su.session_id = s.session_id
Below are the situation when SQL Server will use the temp file.
- usage of table variables or temporary tables
- sql server created intermediate resultsets as worktables in tempdb - usually for sorting purposes (usually is a sign of absent indexes/out-of-date statistics)
- sql server decided to pre-evaluate the resultset of table valued function and in this case it stores the data in tempdb
- recreating indexes with option SORT_IN_TEMPDB = ON
DMV to track the temp file usage for SQLServer的更多相关文章
- cd tom-bash: cannot create temp file for here-document: No space left on device
Linux使用tab补全时提示 cd tom-bash: cannot create temp file for here-document: No space left on device 这是因为 ...
- Linux命令行报错 bash: cannot create temp file for here-document: No space left on device
今天Linux服务器出问题了,使用"tab"补全命令时,提示 bash: cannot create temp file for here-document: No space l ...
- Linux出现cannot create temp file for here-document: No space left on device的问题解决
在终端输入:cd /ho 按tab键时,显示错误: bash: cannot create temp file for here-document: No space left on device 这 ...
- 【linux基础err】bash: cannot create temp file for here-document: No space left on device
博主的device还有剩余空间也出现了这个问题,不知是什么原因,不过删除一些无用的内容,或者将某些有用的内容移动到其他硬盘,之后就可以正常使用了. 参考: 1. cannot create temp ...
- 服务器爆满:cannot create temp file for here-document: No space left on device
1 概述 服务器的磁盘空间被占满导致TAB补全指令失效(TAB会创建临时文件) cannot create temp file for here-document: No space left on ...
- bash: cannot create temp file for here-document: Read-only file system
文件系统被强制只读问题,第一眼看到百度了一下,说可能磁盘坏了.卧槽我都吓懵了系统盘坏了,闹着玩呢,然后接着查资料,排查 mount 查看所有挂载,发现根目录的挂载权限是ro只读. /dev/sda2 ...
- ls bash: cannot create temp file for here-document: No space left on device
出现这种问题,一般是磁盘空间满了,或者是inode满了 使用命令: df -h查询磁盘空间 df -i 查询inode占用 Filesystem Inodes IUsed IFree IUse% Mo ...
- 【应用服务 App Service】App Service使用Git部署时,遇见500错误
问题描述 Azure App Service在部署的时候支持多种方式,如Zip,VS 2019, VS Code,或者是Git部署,当使用Git部署遇见500错误时,可以通过其他的部署方式来验证是否也 ...
- Linux/Unix shell 监控Oracle告警日志(monitor alter log file)
使用shell脚本实现对Oracle数据库的监控与管理将大大简化DBA的工作负担,如常见的对实例的监控,监听的监控,告警日志的监控,以及数据库的备份,AWR report的自动邮件等.本文给出Linu ...
随机推荐
- mysql 截取指定的两个字符串之间的内容(locate,substring)
如需转帖,请写明出处 http://blog.csdn.net/slimboy123/archive/2009/07/30/4394782.aspx 今天我同事在用mysql的时候,需要对一个字符串中 ...
- jquery面试题里 缓存问题如何解决?
jquery面试题里 缓存问题如何解决? 如果直接用jQuery里的$.ajax()方法的话,去除缓存很简单,只需要配置一下缓存属性cache为false,但如果想要简单写法getJSON(),去除缓 ...
- CKEditor实现图片上传
本人用的CKEditor版本为4.3 CKEditor配置和部署参考CKEditor4.x部署和配置. CKEditor编辑器的工具栏中初始的时候应该是这样子的,没有图片上传按钮 并且预览中有一堆火星 ...
- Odoo Entypo Regular Icon List
参考地址: http://www.fontslog.com/entypo-regular-otf-33800.htm#custompreview 或 http://www.w3cplus.com/w3 ...
- 二、saltstack基础配置
super65 master 192.168.1.65 super66 minion 192.168.1.66 主配置文件: [root@super65 ~]# ll /etc/sa ...
- mysql insert插入新形式,再也不需要拼接多重insert啦
注意一下,不能省略表中的任何字段.包括自增id.而且字段的顺序必须和插入表一致 原理是“表插表” INSERT INTO prod_attr select A.* from ( SELECT AS p ...
- Css - 基础的css阴影效果
基本的css3阴影效果 width:971px; height:608px; border:1px solid #ccc; background-color:#fff; filter:progid:D ...
- Windows 8.1/2012R2在脱机模式下安装.NET Framework 3.5
Windows 8.1 1. 插入 Windows 8 DVD 或装载 ISO 映像.在E:\sources\sxs文件夹中找到此功能的源.(本例中为E:\用户的用户已在其加载 Windows 8 ...
- MyEclipse的注册过程
说在前面的话: 说到收费软件MyEclipse,大家可能对它又爱又恨,其实软件收钱也是为了有更好的发展,我们的建议是先试用,如果觉得不错,可以使用正版软件! 准备工作: 1.MyEclipse安装文件 ...
- Javascript 笔记与总结(2-18)正则验证与正则匹配
① 判断 String 是否符合正则要求 patt.test(String); [例]表单提交: a.用户名不能为空,只能是数字及字母,6-11位 b.email 不能为空且格式正确 <!DOC ...