zoukankan      html  css  js  c++  java
  • sqlserver 性能优化常用方法

    查看被锁表:
    
    select   request_session_id   spid,OBJECT_NAME(resource_associated_entity_id) tableName   
    from   sys.dm_tran_locks where resource_type='OBJECT'
    
    spid   锁表进程 
    tableName   被锁表名
    
    解锁:
    
    declare @spid  int 
    Set @spid  = 57 --锁表进程
    declare @sql varchar(1000)
    set @sql='kill '+cast(@spid  as varchar)
    exec(@sql)
    --查看SQL语句CPU高的语句
    
    SELECT TOP 10 TEXT AS 'SQL Statement'
        ,last_execution_time AS 'Last Execution Time'
        ,(total_logical_reads + total_physical_reads + total_logical_writes) / execution_count AS [Average IO]
        ,(total_worker_time / execution_count) / 1000000.0 AS [Average CPU Time (sec)]
        ,(total_elapsed_time / execution_count) / 1000000.0 AS [Average Elapsed Time (sec)]
        ,execution_count AS "Execution Count",qs.total_physical_reads,qs.total_logical_writes
        ,qp.query_plan AS "Query Plan"
    FROM sys.dm_exec_query_stats qs
    CROSS APPLY sys.dm_exec_sql_text(qs.plan_handle) st
    CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) qp
    ORDER BY total_elapsed_time / execution_count DESC
  • 相关阅读:
    php多态简单示例
    php接口
    PHP的两种表单数据提交方式
    PHP操作数据库
    51nod 1575 Gcd and Lcm
    51 nod 1297 管理二叉树
    51 nod 1628 非波那契树
    51 nod 1211 数独 DLX
    51nod:1689 逛街
    51 nod 1203 JZPLCM
  • 原文地址:https://www.cnblogs.com/szytwo/p/4576816.html
Copyright © 2011-2022 走看看