• 查找MSSQL数据库卡顿阻塞可能用到,做个备份


    方法1:

    SELECT  
      [session_id],
      [blocking_session_id] AS '正在阻塞其他会话的会话ID',
      DB_NAME([database_id]) AS '数据库名称',
      [request_id],
      [cpu_time],
      [start_time] AS '开始时间',
      [status] AS '状态',
      [command] AS '命令',
      dest.[text] AS 'sql语句',
      [reads] AS '物理读次数',
      [writes] AS '写次数',
      [logical_reads] AS '逻辑读次数',
      [row_count] AS '返回结果行数',
      [wait_type] AS '等待资源类型',
      [wait_time] AS '等待时间',
      [wait_resource] AS '等待的资源'
      FROM sys.[dm_exec_requests] AS der
      CROSS APPLY
      sys.[dm_exec_sql_text](der.[sql_handle]) AS dest
      WHERE 1=1
       ORDER BY [session_id] DESC

    方法2:

    查询阻塞主机
    with t1 as (
    select  tableName,request_session_id,count(*) cn from (
    select left(OBJECT_NAME(resource_associated_entity_id),50) as tableName,a.request_session_id from sys.dm_tran_locks a WHERE   resource_type = 'OBJECT' ) t
    group by tableName,request_session_id
    )
    ,t2 as
    (
    select session_id,status,host_name,login_name from sys.dm_exec_sessions
    )
    select * from t1 ,t2 where t1.request_session_id=t2.session_id order by 1

  • 相关阅读:
    win7 重装 docker 启动后无法启动错误解决
    ASP.NET MVC 播放远程服务器上的MP3文件
    ubuntu+mono+PetaPoco+Oracle+.net 程序部署
    .NET Core 2.0 问题杂记
    博客园挂了吗?
    Content-Type: application/vnd.ms-excel">
    Storm
    Razor语法
    类型后面加问号 int?
    Apache vue site configuration
  • 原文地址:https://www.cnblogs.com/meigan/p/15205432.html
Copyright © 2020-2023  润新知