Working with SQL Profiler



Similar documents
Database Servers Tutorial

MICROSOFT ACCESS 2007 BOOK 2

QUANTIFY INSTALLATION GUIDE

2 Working with a Desktop GeoDatabase

Use Geodatabase Subtypes and Attribute Domains for Automatic Validation Tutorial

Instructions for Configuring a SAS Metadata Server for Use with JMP Clinical

Personal Geodatabase 101

ArcSDE Database Servers Tutorial

Instructions for Creating an Outlook Distribution List from an Excel File

MONAHRQ Installation Permissions Guide. Version 2.0.4

Taking Advantage of Crystal Reports

Groundwater Chemistry

BSDI Advanced Fitness & Wellness Software

Web Editing Tutorial. Copyright Esri All rights reserved.

SQL Server 2005: SQL Query Tuning

Junk Settings. Options

ArcGIS 9. Installation Guide: Workgroup for Microsoft SQL Server Express

Tool Tip. SyAM Management Utilities and Non-Admin Domain Users

This document details the following four steps in setting up a Web Server (aka Internet Information Services -IIS) on Windows XP:

Creating a File Geodatabase

How to connect to ArcSDE spatial database using OpenOffice and Microsoft Office suites

Tutorial 3. Maintaining and Querying a Database

Microsoft Office 2010

Pharmacy Affairs Branch. Website Database Downloads PUBLIC ACCESS GUIDE

SonicWALL CDP 5.0 Microsoft Exchange InfoStore Backup and Restore

Making a Web Page with Microsoft Publisher 2003

3 Setting up Databases on a Microsoft SQL 7.0 Server

Microsoft FrontPage 2003

MICROSOFT ACCESS TABLES

Table of Contents SQL Server Option

Utilities ComCash

2. Unzip the file using a program that supports long filenames, such as WinZip. Do not use DOS.

Microsoft Access 2007

Census. di Monitoring Installation User s Guide

Prepare your data in ArcGIS for Desktop

MICROSOFT ACCESS 2003 TUTORIAL

Database Forms and Reports Tutorial

Accounts Receivable: Importing Remittance Data

Legal Information Trademarks Licensing Disclaimer

BSDI Advanced Fitness & Wellness Software

How to backup with R1soft

BACKUP UTILITY FOR TIMEFORCE

Linear Referencing Tutorial

What is a Mail Merge?

Using Map Topology Editing Tools

BID2WIN Workshop. Advanced Report Writing

Use the Microsoft Office Word Add-In to Create a Source Document Template for Microsoft Dynamics AX 2012 WHITEPAPER

Setting Up ALERE with Client/Server Data

Excel 2013 What s New. Introduction. Modified Backstage View. Viewing the Backstage. Process Summary Introduction. Modified Backstage View

SonicWALL CDP 5.0 Microsoft Exchange User Mailbox Backup and Restore

Most of your tasks in Windows XP will involve working with information

Outlook 2007: Managing your mailbox

HarePoint Active Directory Self Service Manual

CONFIGURING TARGET ACTIVE DIRECTORY DOMAIN FOR AUDIT BY NETWRIX AUDITOR

Moving the TRITON Reporting Databases

Idera SQL Diagnostic Manager Management Pack Guide for System Center Operations Manager. Install Guide. Idera Inc., Published: April 2013

Microsoft Office Access 2007 which I refer to as Access throughout this book

WatchDox Administrator's Guide. Application Version 3.7.5

Unity Application Suite SQL Server Database Integration

Using the Query Analyzer

Creating a Patch Management Dashboard with IT Analytics Hands-On Lab

MICROSOFT OUTLOOK 2011 READ, SEARCH AND PRINT S

1. CONFIGURING REMOTE ACCESS TO SQL SERVER EXPRESS

System Area Management Software Tool Tip: Integrating into NetIQ AppManager

Lab: Data Backup and Recovery in Windows XP

SQL Tuning and Maintenance for the Altiris Deployment Server express database.

If you have questions or need assistance, contact PCS Technical Services using the contact information on page 10.

Automating Administration with SQL Agent

14 Configuring and Setting Up Document Management

2009 Braton Groupe sarl, All rights reserved.

Search help. More on Office.com: images templates

Moving the Web Security Log Database

Xythos on Demand Quick Start Guide For Xythos Drive

1 of 10 1/31/2014 4:08 PM

TAMUS Remote Desktop Setup For BPP SQL & Alva

ArcGIS 10.1: The Installation and Authorization User Guide

Step One. Step Two. Step Three USING EXPORTED DATA IN MICROSOFT ACCESS (LAST REVISED: 12/10/2013)

Outlook Web App. in Office 365. The Outlook Window. Signing In. (Outlook Exchange Faculty & Staff) Getting Started

Animation in ArcMap Tutorial

Archiving. Follow these steps to archive your

Implementing Mission Control in Microsoft Outlook 2010

Appendix A How to create a data-sharing lab

2012 Teklynx Newco SAS, All rights reserved.

Velocity Web Services Client 1.0 Installation Guide and Release Notes

SQL Server 2008 R2 Express Edition Installation Guide

ArcGIS 10.1 Geodatabase Administration. Gordon Sumerling & Christopher Brown

ONBASE OUTLOOK CLIENT GUIDE for 2010 and 2013

Word 2010: Mail Merge to with Attachments

Installing LearningBay Enterprise Part 2

Results CRM 2012 User Manual

You must have at least Editor access to your own mail database to run archiving.

Call Recorder Quick CD Access System

Citrix EdgeSight User s Guide. Citrix EdgeSight for Endpoints 5.4 Citrix EdgeSight for XenApp 5.4

Crystal Print Control Installation Instructions for PCs running Microsoft Windows XP and using the Internet Explorer browser

Business Warehouse Reporting Manual

Sales Person Commission

Shasta College SharePoint Tutorial. Create an HTML Form

Crystal Reports Installation Guide

How to Import Data into Microsoft Access

Transcription:

Working with SQL Profiler This tutorial complements the article Tracing ArcSDE Queries with SQL Profiler, by Shannon Shields and Joseph Buckles which appeared in the January March 2002 issue of ArcUser magazine. It provides an introduction to tracing queries with SQL Profiler and using SQL Query Analyzer and will teach you how to create a trace template to capture events passed from ArcMap and ArcSDE to Microsoft SQL Server. You will also learn how to Choose events and data columns Set filters in SQL Profiler Evaluate query statements captured by SQL Profiler using the SQL Query Analyzer SQL Profiler and SQL Query Analyzer are performance monitoring tools that are included with SQL Server. These tools can be used by a database administrator to diagnose problems and optimize performance. This tutorial introduces only a small portion of the functionality available with SQL Profiler and SQL Query Analyzer. More information on both tools can be found in the HTML Help file, SQL Server Books Online, available from the Microsoft Web site (www.microsoft.com/sql/techinfo/ productdoc/2000/). To learn more about administering SQL Server with ArcSDE, enroll in ArcSDE Administration for SQL Server, a five-day instructor-led course offered by ESRI. Visit the ESRI Web site (www.esri.com) for information about this course and other resources. Data for This Tutorial The data for this tutorial, based on a dataset containing land-use parcels for Wilson County, North Carolina, consists of a personal geodatabase feature class containing parcel data. Download the archived data file, Parcels.zip, from the ArcUser Online Web site. Important: After downloading and unzipping Parcels.zip, open the parcels personal geodatabase. Copy or import the parcels feature class into ArcSDE. If you do not have permission to load data into ArcSDE, get your ArcSDE administrator to copy the data and grant you SELECT privileges for the feature class. Tutorial Overview Before beginning this tutorial, verify that the ArcSDE server is running and that your HTML Help file, SQL Server Books Online, available from the Microsoft Web site provides, information on SQL Profiler and SQL Querry Analyzer.

login to SQL Server has appropriate permissions to view the data. In this tutorial you will Create a SQL Profiler trace template Connect to ArcSDE from ArcMap Perform an attribute query View the results of the query in SQL Profiler Copy the traced query to SQL Query Analyzer View query statistics Create a column index in ArcCatalog View query statistics using the new index Step 1: Create a SQL Profiler trace template This step defines a new trace definition in SQL Profiler by specifying which events to trace and what type of information to record for each event. A trace template must be created first to store the trace definition. 1. From the Start menu, choose Programs > Microsoft SQL Server > Profiler to start SQL Profiler. 2. From the SQL Profiler menu, choose File > New > Trace Template. 3. Click Save As to save the trace template. 4. Save the Template as tutorial.tdb in the default directory for SQL Server. 5. In the Trace Properties dialog box, click the Events tab. 6. In the Available Event Classes list, expand the Stored Procedures event category by clicking on the plus sign (+) next to it. 7. Select SP:StmtCompleted. 8. Click the Add button to add it to the Selected Event Classes list. 9. Click the Data Columns tab. 10. From the Unselected Data column, add the TextData, Duration, and Reads columns to the Selected data list. 11. Click Save to create the template but do not close SQL Profiler. Step 2: Connect to ArcSDE from ArcMap In this step you will query the Parcels feature class using ArcMap to find Railway right-of-way features. During this step a trace running in SQL Profiler will capture the Add the TextData, Duration, and Reads columns to the Selected data list when defining the Trace Properties. Working with SQL Profiler Page 2

SELECT statements submitted by ArcSDE to SQL Server. 1. Start ArcMap with a new empty map. 2. Choose File > Add Data and navigate to the Database Connections folder. 3. Connect to the ArcSDE server where the Parcels feature class is stored. 4. Add the Parcels feature class to the map. 5. Return to SQL Profiler. 6. Start a new trace by choosing File > New > Trace. 7. In the Connect to SQL Server dialog box, click on the ellipsis ( ) and choose the name of your SQL Server from the list. 8. Connect using your SQL Server login. (If necessary, check with your ArcSDE administrator for the appropriate method to connect). 9. For Trace name, enter Profiler Tutorial. 10. From the Template name dropdown list, choose Tutorial and click Run. The Trace will start running in its own window. Multiple traces can be run simultaneously, each in its own window. Traces can be saved to a trace file on disk or to a trace table in the database. Because tracing uses system resources that might otherwise be allocated to other SQL Server processes, do not leave traces running unless you are monitoring for a particular event. For the remainder of this tutorial, you will use and modify the Profiler Tutorial trace. After using Select by Attributes in ArcMap to query the MBL column in the parcels feature class, you will inspect the results of the query and use filters to limit the type of statements that SQL Profiler captures. You will also inspect the statements sent by the gsrvr process to SQL Server, and examine the execution plans for those statements using SQL Query Analyzer. Finally, you will index the MBL column to improve query performance. [The giomgr in ArcSDE spawns a gsrver process for each singleuser application connection. The gsrver process handles the communication between ArcMap and SQL Server.] Step 3: Perform an attribute query in ArcMap 1. Return to ArcMap and choose Selection > Select by Attributes. 2. In the SELECT * FROM text box, enter MBL = Railroad_right_of_way 3. Click the Verify button. 4. After the syntax is verified, click Apply to execute the query. Forty-one features should be selected and highlighted. In the Connect to SQL Server dialog box, click on the ellipsis ( ) and choose the name of your SQL Server from the list. Choose Selection > Select by Attributes to query for Railroad rightof-way features. Working with SQL Profiler Page 3

Step 4: View the results of the query in SQL Profiler Return to SQL Profiler and examine the SP:StmtCompleted statements. These statements are queries that the gsrvr process submitted to SQL Server to fetch the Railroad right-of-way features from the Parcels feature class. The trace captured many statements and the majority of them have a value of zero (0) for the Duration, CPU, Reads, and Writes columns. These statements aren t useful for purposes of this tutorial. A filter will be applied so that the trace will capture only statements containing a value equal to or greater than one (1) in the Reads column. Another filter will be added that will allow SQL Profiler to return only SELECT statements. 1. In SQL Profiler, click the Stop Trace button. 2. Click the Properties button. 3. In the Trace Properties dialog box, click on the Filters tab. 4. Expand Reads from the Trace Event Criteria list. 5. Expand Greater Than or Equal To. 6. Enter 1 in the textbox and press Enter. 7. Expand TextData under Trace Event Critera. 8. Expand Like and select% in the text box. Press Enter. 9. Click Run. These two filters will limit the events that are returned by the trace. The Reads event criteria is the number of logical reads performed by the server executing the statement. The first filter specifies that only operations that perform at least one logical read will be returned by the trace. The TextData event criteria returns text contained within the event data and specifies that only statements that begin with the word SELECT will be returned by the trace. With the filters set, rerun the query in ArcMap. 1. Return to ArcMap choose Selection > Clear Selected Features. 2. Choose Selection > Select By Attributes. 3. Click Apply to execute the query. 4. Return to SQL Profiler and examine the new results. You should now see a single SP:StmtCompleted statement. 5. Click on the SP:StmtCompleted event and examine the text of the statement in the lower pane of the trace window. This is the full text of the query you submitted from ArcMap. The the majority of the statements have a value of zero (0) for the Duration, CPU, Reads, and Writes columns. Setting a filter will limit the statements that SQL Profiler captures. Working with SQL Profiler Page 4

Step 5: Copy the traced query to SQL Query Analyzer 1. In SQL Profiler, click the Stop Trace button to stop the Profiler Tutorial trace. 2. Select the entire text of the SP:StmtCompleted SELECT statement in the lower pane of the query window and press Ctrl+C to copy it. 3. Choose Start > Programs > Microsoft SQL Server > SQL Query Analyzer. 4. Connect to your SQL Server with the appropriate connection method. In the query window, right-click and choose Paste to paste the SP:StmtCompleted SELECT statement into SQL Query Analyzer. 5. If the feature class is stored in a database other than the one that your login automatically connects to, choose that database from the Database dropdown list. 6. Press Ctrl+K to show the execution plan. [The execution plan in rather than displaying them in tabular form. It can also accessed by choosing Query > Display Execution Plan. For an explanation of the icons used, consult SQL Server Books Online.] 7. Choose Tools > Tools > Options from the SQL Profiler menu. 8. In the Options dialog box, click the Connection Properties tab. 9. Check the box next to Set Statistics I/O option and click OK. Now the SQL Query Analyzer will show the I/O statistics for statements executed from the query window. You will examine these values after executing the query. Step 6: View query statistics 1. Press Ctrl+E to execute the SP:StmtCompleted SELECT statement copied from SQL Profiler to SQL Query Analyzer. 2. Scroll to the end of the query results to see the I/O statistics for the Business and Feature tables for the Parcels feature class. Questions How many logical reads were performed on the Parcels table. (Logical reads represent the total number of data and index pages that were read by SQL Server to return query results.) How many features were selected by this query? Note that relatively few features were selected compared to the number of pages that were read. Next, look at the execution plan by clicking the Execution Plan tab at the bottom of the query window. The query was resolved by scanning the entire Parcels business table for values that matched the query s WHERE clause (MBL = SQL Query Analyzer uses icons to graphically represent the execution of specific statements and queries in SQL Server. Create a column index on MBL in ArcCatalog Working with SQL Profiler Page 5

Railroad_right_of_way ). This is not the most efficient method of searching for values. In the next section, you will create a column index and observe what happens when the query uses this index. Step 7: Create a column index in ArcCatalog 1. Without saving the map document, close ArcMap. 2. Open ArcCatalog and navigate to your ArcSDE Server connection. 3. Right-click the Parcels feature class and choose Properties. 4. In the Feature Class Properties dialog box, click the Indexes tab. 5. In the Attribute Indexes section, click the Add button. 6. In the Attribute Indexes text box, type MBL_idx. Select MBL from the Fields Available list and add it to the Fields Selected list. 7. Click Apply then OK. You have just created an index on the MBL column. What affect do you think this will have on the execution of the query? 1. Return to SQL Query Analyzer. 2. In the query window, above the SELECT query, insert the following line dbcc dropcleanbuffers The new query executes uses an Index Seek and a Bookmark Lookup operation to find the features whose MBL values matched the query. Summary In this tutorial you learned how to create and execute a trace from SQL Profiler and saw one way in which you could use the statements returned by a trace. After isolating statements in SQL Profiler, the SQL Query Analyzer was used to asses the impact of these statements on system performance. 3. Press Ctrl+E to execute both statements. Questions How many logical reads were performed for the Parcels table? Were there fewer logical reads this time? View the execution plan (Ctrl+K). The query should have executed using an Index Seek and a Bookmark Lookup operation to find the features whose MBL values matched the query. An Index Seek is used by the Query Optimizer when an index is present and can be searched for explicit values. A Bookmark Lookup uses a bookmark (i.e., index key) to lookup a corresponding row in another table. The Bookmark Lookup operation found the corresponding features in the Feature table for the Parcels feature class. For queries that return a small number of features, using the more complex Index Seek and Bookmark Lookup, instead of an Index Scan operation, is much more efficient. The SQL Server Index Tuning Wizard can help you determine if commonly executed queries would benefit from column indexes. After examining the query, close SQL Query Analyzer and SQL Profiler. Working with SQL Profiler Page 6