获取SQL段的执行时间
对SQL进行优化 经常会需要知道这条SQL语句执行的时间,这里介绍我的一种常用做法
DECLARE @d DATETIME
SET @d=GETDATE() --do something
--for example
SELECT * FROM Table1 WITH(NOLOCK) SELECT [语句执行花费时间(毫秒)]=DATEDIFF(ms,@d,getdate())
DATEDIFF() 函数返回两个日期之间的天数,用法 DATEDIFF(datepart,startdate,enddate)
其中 startdate 和enddate 非别是要计算时间差的开始时间和结束时间 datepart 是间隔时间的类型
| datepart | 缩写 |
|---|---|
| 年 | yy, yyyy |
| 季度 | qq, q |
| 月 | mm, m |
| 年中的日 | dy, y |
| 日 | dd, d |
| 周 | wk, ww |
| 星期 | dw, w |
| 小时 | hh |
| 分钟 | mi, n |
| 秒 | ss, s |
| 毫秒 | ms |
| 微妙 | mcs |
| 纳秒 | ns |
---恢复内容结束---
获取SQL段的执行时间的更多相关文章
- 获取sql执行时间
sql server中获取要执行的sql或sql块的执行时间,方法之一如下: declare @begin datetime,@end datetime set @begin =getdate() - ...
- MyBatis7:MyBatis插件及示例----打印每条SQL语句及其执行时间
Plugins 摘一段来自MyBatis官方文档的文字. MyBatis允许你在某一点拦截已映射语句执行的调用.默认情况下,MyBatis允许使用插件来拦截方法调用 Executor(update.q ...
- mysql 获取一段时间的数据
用 sql 获取一段时间内的数据: SELECT * FROM EDI.edi_history WHERE timestampdiff(day, SYSDATE(), create_time_loc) ...
- MyBatis插件及示例----打印每条SQL语句及其执行时间
Plugins 摘一段来自MyBatis官方文档的文字. MyBatis允许你在某一点拦截已映射语句执行的调用.默认情况下,MyBatis允许使用插件来拦截方法调用 Executor(update.q ...
- sql中的系统表sysobjects以及如何查看sql语句的执行时间
使用sysobjects可以快速查看数据库中表.视图.存储过程.触发器.约束等的信息. 大牛文章:http://www.cnblogs.com/atree/p/SQL-Server-sysobject ...
- EXPLAIN PLAN获取SQL语句执行计划
一.获取SQL语句执行计划的方式 1. 使用explain plan 将执行计划加载到表plan_table,然后查询该表来获取预估的执行计划 2. 启用执行计划跟踪功能,即autotrace功能 3 ...
- 使用ttXactAdmin、ttSQLCmdCacheInfo、ttSQLCmdQueryPlan获取SQL相关具体信息[TimesTen运维]
使用ttXactAdmin.ttSQLCmdCacheInfo.ttSQLCmdQueryPlan获取SQL相关具体信息,适合于tt11以上版本号. $ ttversion TimesTen Rele ...
- 如何在Sql2008中获取表字段属性和注释?
如何在Sql2008中获取表字段属性和注释? select b.[value] from sys.columns a left join sys.extended_properties b on a. ...
- Java 获取SQL查询语句结果
step1:构造连接Class.forName("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnec ...
随机推荐
- Resizable 2th click not working
here's a simple solution. just destroy the resizable function, then rebuild it. try { $("#div& ...
- IOS开发之Post 方式获取服务器数据
//1.创建post方式的 参数字符串url +(NSString *)createPostURL:(NSMutableDictionary *)params { NSString *postStri ...
- 改变和恢复view的方向
self.navigationController.view.transform = CGAffineTransformMakeRotation(M_PI/2); self.navigationCon ...
- [AngularJS] angular-md-table for Angular material design
Download from npm:https://www.npmjs.com/package/angular-md-table +: Responsive: Has both Mobile view ...
- http to https automatic--weblogic/jboss/tomcat--reference
weblogic reference from:http://middlewaremagic.com/weblogic/?p=2019 Many times we want to secure our ...
- TreeSet与TreeMap
TreeSet底层使用的存储容器为TreeMap TreeMap使用红黑树(一种自平衡的排序二叉树)实现,检索效率为O(logn) 红黑树的三个基本操作:左旋.右旋.着色 平衡二叉树:空树或左右子树高 ...
- 关于安装PHP补装PDO与PDO_MYSQL操作
我这里是通过PHP源码包来安装的 1.安装pdo cd到你的PHP源码包下的ext/pdo目录,然后执行如下操作: #/usr/local/php/bin/phpize (/usr/local/p ...
- C#_串口程序_二次打包_事件响应
using System;using System.IO.Ports;using System.Windows.Forms; namespace Dll_Serial_Comm{ public ...
- hdu 1880 字符串hash
/*普通的hsah 由于元素太多 空间很小..hash碰撞很厉害.30分*/ #include<iostream> #include<cstdio> #include<c ...
- bootstrap初探2
控制是否显示:visible-(lg | md | sm |sx)-(block | inline | inline-block), hidden-(lg | md | sm |sx) <!DO ...