Free Newsletters:
DatabaseDaily  
Database Journal
Search Database Journal:
 
MS SQL Oracle DB2 Access MySQL PostgreSQL Sybase PHP SQL Etc SQL Scripts & Samples Links Database Forum DBA Videos
internet.com

» Database Journal Home
» DBA Videos
» Database Articles
» Database Tutorials
MS SQL
Oracle
MS Access
MySQL
DB2
» RESOURCES
Database Tools
SQL Scripts & Samples
Links
» Database Forum
» DBA Jobs
» Sitemap

News Via RSS Feed



follow us on Twitter

Marketplace Partners
Be a Marketplace Partner

internet.commerce
Be a Commerce Partner


















Security Software Primed for Strong Growth

SAP Touts 'Unwired' Strategy With Sybase

Salesforce Q2 Sees SaaS Paying Off

internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Database Journal | DBA Support | SQLCourse | SQLCourse2









Web Developer/Designer
Targus
US-CA-Anaheim

Justtechjobs.com Post A Job | Post A Resume

Featured Database Articles

MS SQL

July 30, 2003

Scripting Traces for Performance Monitoring on SQL Server

By Andrew Novick

The SQL Profiler is a great tool for monitoring and analyzing SQL Server Performance. I use it all the time to watch the detailed actions of a stored procedure, trigger or user-defined function (UDF) that I am developing. It can also be used to monitor aggregate performance of an entire SQL Server instance, a single database, or to isolate performance problems. When you are interested in overall performance, using SQL Profiler over time, by that I mean every day, improves your knowledge of your system and its performance characteristics and provides the information you need to spot trends and changes of behavior.

SQL Profiler is a graphical interface to SQL Server's trace capability but it is not the only way to run a trace. Calling a group of system stored procedures, whose names all begin with the characters "sp_trace_", can also create them. In fact, SQL Profiler uses these stored procedures behind the scenes to do the tracing that you request.

Traces can be sent to the SQL Profiler window, a database table or a sequential disk file. However, tracing is not resource free. In fact, it can consume considerable resources, particularly if you send the trace to SQL Profiler. Since the most important time to monitor is the time of maximum server load, you do not want the act of measurement to slow the system unnecessarily. For most applications that run in a business environment, peak activity occurs in the middle of the afternoon.

The disk file is by far and away the fastest destination for a trace and it interferes the least with the performance of SQL Server. However, for analysis purposes, a table is the best destination. Once the data is in a table, the information can be sliced and diced to your heart's content. Most importantly, trend reporting, using data from multiple days, is possible.

This article presents a technique for writing a stored procedure that creates a trace. To achieve the best performance the proc sends its output to a file on disk. A second step moves the data from the trace file into a SQL table for analysis. The second step doesn't have to be performed exactly when the data is recorded. In fact, it's usually loaded overnight when server utilization is low and then followed by any standard reports. By using the file as the trace destination and loading the data overnight, this solution does the best to minimize the peak-hour resources required for monitoring.

Although you could manually use the SQL Profiler to create a trace at the same time every day and send it to a file, it is difficult to be consistent and this is a task that is easily automated. By using the stored procedure and a SQL Job that runs the stored procedure, you can run the exact same trace at the same time of day, every day. This kind of data gathering provides consistent information for effective performance analysis.

The most tedious part of the process is creating the stored procedure that executes the trace. Fortunately, SQL Profiler will write almost all of it for you. With a few modifications, it is easy to turn its script into a stored procedure that can be run on a schedule.



Go to page: 1  2  3  Next  

Tools:
Add databasejournal.com to your favorites
Add databasejournal.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x
Receive news via our XML/RSS feed

MS SQL Archives








Latest Forum Threads
MS SQL Forum
Topic By Replies Updated
SSRS, Sharepoint or ASP.NET kappa02 1 August 31st, 08:59 AM
Ad/ldap & sql 2005 (7321) kappa02 4 August 30th, 03:58 PM
Sql SerVer Restore SaranSaki 3 August 27th, 02:15 PM
DTS Excel data exceeds 65536 rows ssingh 1 August 13th, 09:55 AM