Introduction to Profiler

SQL Server Profiler — or just Profiler — is a tool that can help monitor all the queries that are being run on your database. This allows you to see a lot of information including CPU time, reads, writes, duration, and even the text or stored proc being called along with the parameters.

That last part can be especially useful. When you see a stored procedure that is taking a particularly long time to run, you can always copy the TextData section (which will have the query along with its parameters) and paste it into SQL Server Management Studio. The nice part about this is you can then run the same stored procedure with the same parameters and get an execution plan to tell you what is slowing things down.

Using Profiler

First off, we need to open up a session of Profiler. There are two ways to do this. If you have SQL Server Management Studio open already, then you can go to the Tools drop-down on the menu bar and open SQL Server Profiler.

The other approach is to open Profiler directly from the Windows menu, as it can run as a standalone application without SSMS.

Either one of these approaches will open Profiler to the normal Connect to Server login page. You should already have a login for this as you’re supposed to be working on this database. Once you’re past the login page, you’ll get a Trace Properties page.

Trace Properties

The first tab (General) can usually be ignored if you just want to do a quick trace on something. But if you are a more frequent user, this tab lets you set up several options.

Templates are predefined traces that either came with Profiler as a built-in template or were set up in a previous session by someone else.

Save to File/Table allows you to do just that. You can save the trace to either a file or table for review later. Please note that you can also save off your trace manually if you’re so inclined.

Enable Trace Stop Time allows you set a date/time where Profiler will stop. This is a good option for long-running traces that you may not want to run through a heavy load period. Don’t forget, running Profiler does add some additional overhead to your database so leaving it running all the time is not the best idea.

Selecting Events

The last tab, Events Selection, allows us to select all of the actual events we want to see.
If you selected one of the templates from the previous tab (or if you just cycle through them), you’ll notice there are a lot of events to watch for. Of course, there is always the Show All Events checkbox, but this can be overwhelming if you’re just looking for your slower-running queries.

For most cases where I am simply looking for slow-running queries, I will go with all of the Stored Procedure events as well as the TSQL events. You can even throw in the Lock events for good measure.

Narrowing Our Search

Before we hit run, there are a couple of more things we need to do to narrow our search down.

If you run the Trace as it is, we will see a limited set of things but it will still be a lot. There are many queries and processes that run and most of them take only a few milliseconds. But as milliseconds and sub-millisecond running-queries are not what we are after, we need a way to filter those out. That’s where the Column Filters button comes in handy.

After clicking on the Column Filters button, we get the following dialog:

This is helpful in that it allows us to filter out rows that would otherwise clutter things up. As mentioned before, we are not looking for the queries that are running fast already. (Although it’s always interesting to see just how many times those are called, but that can be another performance issue altogether…)

As you can see, there are several items we can filter. For our purposes, we are interested in the duration. The duration field is length of time it takes the stored procedure to run in milliseconds.

So, if we want to screen out the stored procs that took less than a second to run, we would set the Greater Than or Equal value to 1,000 and check the Exclude rows that do not contain values checkbox.

After hitting OK, we return to our Events Selection screen. At this point, we can hit Run and get a results screen that looks like one below:

On a normal, active database, you would see something pop up here after just a few seconds as there is always plenty of traffic. The higher you set the duration value, though, the less you will see simply because most queries run fairly quickly.

Here is an image of the results of a trace with a filter set to 10 milliseconds. Note that you can see the duration, reads, writes, and more importantly, the TextData, which tell us the SP and parameters of the queries that run slower than our filter.

Quick Introduction to SQL Server Profiler的更多相关文章

  1. SQL Server Profiler

    一.SQL Profiler工具简介 SQL Profiler是一个图形界面和一组系统存储过程,其作用如下: 图形化监视SQL Server查询: 在后台收集查询信息: 分析性能: 诊断像死锁之类的问 ...

  2. SQL Server Profiler使用教程,通俗易懂才是王道

    做开发,平时难免和数据库打交道,特别是写存储过程,对于我们这些不常写SQL的人来说是一件极其痛苦的事,每次写完运行总是有错,如果用的是本地数据库的话还好,可以在本机调试SQL,那如果在数据库在服务器上 ...

  3. SQL Server Profiler教程

    SQL Server Profiler是SQL Server企业版自带的一个sql 语句跟踪和分析工具,功能十分强大.熟练地使用它,对我们分析数据库性能问题很有帮助,比如当数据访问使用EF等ORM框架 ...

  4. SQL Server Profiler工具

    一.SQL Profiler工具简介 SQL Profiler是一个图形界面和一组系统存储过程,其作用如下: 图形化监视SQL Server查询: 在后台收集查询信息: 分析性能: 诊断像死锁之类的问 ...

  5. SQL2005 : 如何在SQL Server Profiler (事件查看器)中 跟踪查看死锁恢复

    SQL Profiler 通过 SQL Profiler 工具程序,可监控应用程序如何访问数据库引擎.普通来说,当系统性能需要优化或是应用程序对数据库访问的结果不合预期,都可以使用该工具确认视图问题所 ...

  6. SQL Server Profiler使用方法

    一.SQL Server Profiler使用方法 1.单击开始--程序--Microsoft SQL Server 2005--性能工具--SQL Server Profiler,如下图:   2. ...

  7. 降龙十八掌之一:(亢龙有悔)SQL Server Profiler和数据库引擎优化顾问

    简介 说到Sql的[性能工具]真是强大,SQL Server Profiler的中文意思是SQL Server事件探查,这个到底是做什么用的呢?我们都知道探查的意思大多是和监视有关,其实这个SQL S ...

  8. SQL Server Profiler:使用方法和指标说明

    SQL Server Profiler的中文意思是SQL Server事件探查,一个Sql的监视工具,可以具体到每一行Sql语句,每一次操作,和每一次的连接.感觉这个工具的作用还是很大的,给大家分享一 ...

  9. 解决 SQL Server Profiler 跟踪[不断]出现检索数据

    问题简单回顾: 当我们使用SQL Server Profiler根据数据时,有时刚打开什么也没干呢,就显示很多数据了,当我们用橡皮擦清除,没过两秒就又有了,如图: 是不是很恼火!~不怕,解决方案如下: ...

随机推荐

  1. Java多线程(十)——线程优先级和守护线程

    一.线程优先级的介绍 java 中的线程优先级的范围是1-10,默认的优先级是5.“高优先级线程”会优先于“低优先级线程”执行. java 中有两种线程:用户线程和守护线程.可以通过isDaemon( ...

  2. C#高性能二进制序列化

    二进制序列化可以方便快捷的将对象进行持久化或者网络传输,并且体积小.性能高,应用面甚至还要高于json的序列化:开始之前,先来看看dotcore/dotne自带的二进制序列化:C#中对象序列化和反序列 ...

  3. zookeepeer使用java api

    一.引入依赖 <!-- https://mvnrepository.com/artifact/org.apache.zookeeper/zookeeper --> <dependen ...

  4. Spring Boot 2.0(八):Spring Boot 集成 Memcached

    Memcached 介绍 Memcached 是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载.它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提高动态.数据库驱动网站 ...

  5. linux if -d -e -f表达的意思

    文件表达式-e filename 如果 filename存在,则为真-d filename 如果 filename为目录,则为真 -f filename 如果 filename为常规文件,则为真-L ...

  6. C#.NET 大型通用信息化系统集成快速开发平台 4.1 版本 - 即时消息提醒功能改进

    可以给自己的信息管理系统增加一些即时消息提醒功能,简单方便,一般是一行代码就可以发送提醒信息了,方便二次开发,个性化改进. 1:可以用简拼,快速查找内部员工. 2:双击直接可以发QQ消息. 3:双击直 ...

  7. Go源码编译安装

    参考文档1:https://www.cnblogs.com/majianguo/p/7258975.html 参考文档2:http://www.loongson.cn/news/company/456 ...

  8. python第六章:三大利器(装饰器,迭代器,生成器)--小白博客

    python装饰器 什么是装饰器?在不修改源代码和调用方式的基础上给其增加新的功能,多个装饰器可以装饰在同一个函数上 # 原理(个人理解):将原函数(bar)的内存地址重新赋值,进行覆盖.新值为装饰器 ...

  9. python四:函数练习--小白博客

    为什么要有函数?函数式编程定义一次,多出调用函数在一定程度上可以理解为变量函数的内存地址加上()就是调用函数本身也可以当做参数去传参 不用函数:组织结构不清晰代码的重复性 def test():#te ...

  10. iOS- 利用AFNetworking(AFN) - 实现文件断点下载

    https://www.cnblogs.com/qingche/p/3500746.html 1. 定义一个全局的AFHttpClient:包含有 1> baseURL 2> 请求 3&g ...