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段语句一起运行)。

  • 相关阅读:
    初探Remoting双向通信(三)
    MySQL主从复制
    MySQL锁机制
    mySql索引
    连接池
    JDBC
    数据库建表、约束、索引
    Oracle和SQL简介
    Stream API 和 注解
    lambda表达式
  • 原文地址:https://www.cnblogs.com/leku_cc/p/1837140.html
Copyright © 2011-2022 走看看