Working With SQL Profiler

7m ago
7 Views
1 Downloads
694.07 KB
6 Pages
Last View : 28d ago
Last Download : 3m ago
Upload by : Ryan Jay
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. Add the TextData, Duration, and Reads columns to the Selected data list when defining the Trace Properties. 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 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. In the Connect to SQL Server dialog box, click on the ellipsis ( ) and choose the name of your SQL Server from the list. 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. Working with SQL Profiler Choose Selection Select by Attributes to query for Railroad rightof-way features. 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. The the majority of the statements have a value of zero (0) for the Duration, CPU, Reads, and Writes columns. 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. Working with SQL Profiler Setting a filter will limit the statements that SQL Profiler captures. 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. SQL Query Analyzer uses icons to graphically represent the execution of specific statements and queries in SQL Server. 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 Working with SQL Profiler Create a column index on MBL in ArcCatalog 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. The new query executes uses an Index Seek and a Bookmark Lookup operation to find the features whose MBL values matched the query. 4. In the Feature Class Properties dialog box, click the Indexes tab. 5. In the Attribute Indexes section, click the Add button. Summary 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. 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. 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 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

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.

Related Documents:

Compute Command Line Profiler DU-05982-001_v03 4 COMPUTE COMMAND LINE PROFILER OVERVIEW This document is intended for users of Compute Command Line Profiler for NVIDIA CUDATM technology. Compute Command Line Profiler is a command line based profiling tool that can be used to measure performance and find potential opportunities for

SQL Server supports ANSI SQL, which is the standard SQL (Structured Query Language) language. However, SQL Server comes with its own implementation of the SQL language, T-SQL (Transact- SQL). T-SQL is a Microsoft propriety Language known as Transact-SQL. It provides further capab

MS SQL Server: MS SQL Server 2017, MS SQL Server 2016, MS SQL Server 2014, MS SQL Server 2012, MS SQL Server 2008 R2, 2008, 2008 (64 bit), 2008 Express, MS SQL Server 2005, 2005 (64 bit), 2005 Express, MS SQL Server 2000, 2000 (64 bit), 7.0 and mixed formats. To install the software, follow the steps: 1. Double-click Stellar Repair for MS SQL.exe.

Server 2005 , SQL Server 2008 , SQL Server 2008 R2 , SQL Server 2012 , SQL Server 2014 , SQL Server 2005 Express Edition , SQL Server 2008 Express SQL Server 2008 R2 Express , SQL Server 2012 Express , SQL Server 2014 Express .NET Framework 4.0, .NET Framework 2.0,

70 Microsoft SQL Server 2008: A Beginner’s Guide SQL_2008 / Microsoft SQL Server 2008: ABG / Petkovic / 154638-3 / Chapter 4 In Transact-SQL, the use of double quotation marks is defined using the QUOTED_ IDENTIFIER option of the SET statement. If this option is set to ON, which is theFile Size: 387KBPage Count: 26Explore furtherLanguage Elements (Transact-SQL) - SQL Server Microsoft Docsdocs.microsoft.comThe 33 languages of SQL Server Joe Webb Blogweblogs.sqlteam.comThe Language of SQL Pdf - libribooklibribook.comSql And The Standard Language For Relational Database .www.bartleby.comdatabase - What are good alternatives to SQL (the language .stackoverflow.comRecommended to you based on what's popular Feedback

Use \i FULL_PATH_ass1.sql to load your ass1.sql where FULL_PATH_ass1.sql is the full path of your answer file (ass1.sql) Use \i FULL_PATH_check1.sql to load check1.sql where FULL_PATH_check1.sql is the full path of the check file (check1.sql) reate a new database for mymy2 database. Repeat the above steps using mymy2.dump and check2.sql

SQL Server 2005 SQL Server 2008 (New for V3.01) SQL Server 2008 R2 (New for V3.60) SQL Server 2012 (New for V3.80) SQL Server 2012 R2 (New for V3.95) SQL Server 2014 (New for V3.97) SQL Server 2016 (New for V3.98) SQL Server 2017 (New for V3.99) (Recommend Latest Service Pack) Note: SQL Server Express is supported for most situations. Contact .

AngularJS Tutorial, AngularJS Example pdf, AngularJS, AngularJS Example, angular ajax example, angular filter example, angular controller Created Date 11/29/2015 3:37:05 AM