在SQL Server中使用sp_WhoIsActive监视活动

In this article, we will talk about sp_WhoIsActive stored procedure and how we can use it to monitor currently running activities in SQL Server.

在本文中,我们将讨论sp_WhoIsActive存储过程以及如何使用它来监视SQL Server中当前正在运行的活动。

介绍 (Introduction)

Database administrators (DBAs) are incessantly checking currently running operations over an SQL Server instance especially when the server is slowing down.

数据库管理员(DBA)不断检查SQL Server实例上当前正在运行的操作,尤其是在服务器速度变慢时。

In general, Microsoft provided two system stored procedures called “sp_who” and “sp_who2” to retrieve all currently running processes on the instance but they lack much useful information that can facilitate the performance monitoring and analysis process, also they show much useless information (system processes).

通常,Microsoft提供了两个名为“ sp_who”和“ sp_who2”的系统存储过程来检索实例上所有当前正在运行的进程,但是它们缺少许多有用的信息来促进性能监视和分析过程,并且它们还显示了很多无用的信息(系统流程)。

For this reason, Adam Machanic (a Microsoft MVP since 2004) developed a more powerful stored procedure called “sp_whoisactive” to fill in the gap between the actual needs of DBAs and the currently provided procedures (sp_who and sp_who2).

因此, Adam Machanic (自2004年起成为Microsoft MVP)开发了一种功能更强大的存储过程,称为“ sp_whoisactive ”,以填补DBA实际需求与当前提供的过程(sp_who和sp_who2)之间的差距。

In the following sections, we will talk briefly about sp_who and sp_who2 stored procedure, then we will illustrate how to download and use sp_whoisactive stored procedure.

在以下各节中,我们将简要讨论sp_who和sp_who2存储过程,然后将说明如何下载和使用sp_whoisactive存储过程。

sp_Who和sp_Who2 (sp_Who and sp_Who2)

As we mentioned before, Microsoft provided sp_Who and so_Who2 stored procedures for activity monitoring in SQL Server. In this section, we will explain what is the information returned by each stored procedure and what are the differences between them.

如前所述,Microsoft提供了sp_Who和so_Who2存储过程来监视SQL Server中的活动。 在本节中,我们将解释每个存储过程返回的信息是什么以及它们之间的区别是什么。

As described in the official documentation, sp_who “provides information about current users, sessions, and processes in an instance of the Microsoft SQL Server Database Engine. The information can be filtered to return only those processes that are not idle, that belong to a specific user, or that belong to a specific session.”

官方文档中所述,sp_who “提供有关Microsoft SQL Server数据库引擎实例中当前用户,会话和进程的信息。 可以对信息进行过滤,以仅返回那些不是空闲的,属于特定用户或属于特定会话的进程。”

sp_who returns information such as the session process ID (SPID), the execution context ID (ECID), the process status, the blocking session ID, the database name, the login and hostname associated with this process, and the command type.

sp_who返回信息,例如会话进程ID(SPID),执行上下文ID(ECID),进程状态,阻塞会话ID,数据库名称,与此进程关联的登录名和主机名以及命令类型。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值