zoukankan      html  css  js  c++  java
  • 详细记录sql运行时间(精确到毫秒)

    一、
    declare @d datetime
    set @d=getdate()

    select top 1 id,***,***,***
    from *** as t2 with (nolock)
    where t2.*** = '***' and t2.*** = '***' and t2.*** = '***' AND t2.***>-1


    select [语句执行花费时间(毫秒)]=datediff(ms,@d,getdate())
    set @d=getdate()


    select top 1 id,***,***,*** from ***.dbo.*** as t2 with (nolock)
    where t2.*** = '***' and t2.ShiPY = '***' and t2.LabelPY = '***' AND t2.***=4

    select [语句执行花费时间(毫秒)]=datediff(ms,@d,getdate())
    set @d=getdate()

    二、

    SET STATISTICS profile ON
    SET STATISTICS io ON
    SET STATISTICS time ON
    GO

    --sql语句

    select top 1 id,***,***,***
    from *** as t2 with (nolock)
    where t2.*** = '***' and t2.*** = '***' and t2.*** = '***' AND t2.***>-1

    GO
    SET STATISTICS profile OFF
    SET STATISTICS io OFF
    SET STATISTICS time OFF

    这个是SQL server 中自带的。 执行完后看消息栏里面 分析很详细(注意 一定要3段语句一起运行)。

  • 相关阅读:
    MySQL
    MySQL
    MySQL
    javaScript之深度理解原型链
    javaScript之this的五种情况
    ES6之箭头函数中的this
    javaScript之跨浏览器的事件对象
    javaScript之事件处理程序
    javaScript之promise
    VUE之使用百度地图API
  • 原文地址:https://www.cnblogs.com/leku_cc/p/1837140.html
Copyright © 2011-2022 走看看