IT tutorials
 
Database
 

SQL Server 2008 R2 : Query Analysis - Query Analysis with SQL Server Profiler

12/10/2012 11:13:54 AM
- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

SQL Server Profiler serves as another powerful tool available for query analysis. When you must monitor a broad range of queries and database activity and analyze the performance, it is difficult to analyze all those queries manually. For example, if you have a number of stored procedures to analyze, how would you know which ones to focus on as problem procedures? You would have to identify sample parameters for all of them and manually execute them individually to see which ones were running too slowly and then, after they were identified, do some query analysis on them.

With SQL Server Profiler, you can simply define a trace to capture performance-related statistics on the fly while the system is being used normally. This way, you can capture a representative sample of the type of activity your database will receive and capture statistics for the stored procedures as they are being executed with real data values. Also, to avoid having to look at everything, you can set a filter on the Duration column so that it displays only items with a runtime longer than the specified threshold.

The events you want to capture to analyze query performance are listed under the Performance events. They include Showplan All, Showplan Statistics Profile, Showplan Text, Showplan Text (Unencoded), Showplan XML, Showplan XML for Query Compile, and Showplan XML Statistics Profile. The data columns that you want to be sure to include when capturing the showplan events are TextData, CPU, StartTime, Duration, and Reads and Writes. Also, for the Showplan Statistics and Showplan All events, you must also select the BinaryData data column.

You can easily save the trace information to a file or table for replaying the sequence to test index or configuration changes, or simply for historical analysis. If you choose any of the Showplan XML options, you have the option of saving the XML Showplan events separately from the overall trace file. You can choose to save all XML Showplan events in a single file or separate file for each event (see Figure 1). You can then load the Showplan XML file into SSMS to view the graphical execution plans and perform your query analysis.

Figure 1. Saving XML Showplan events to a single file.

When you run a SQL Server Profiler trace with the Showplan XML event enabled, SQL Server Profiler displays the graphical execution plans captured in the bottom display panel of the Profiler window when you select a record with a Showplan XML EventClass. The graphical execution plans displayed in SQL Server Profiler are just like the ones displayed in SSMS, and they also include the same detailed information available via the ToolTips. Figure 2 shows an example of a graphical execution plan being displayed in SQL Server Profiler.

Figure 2. Displaying an XML Showplan event in SQL Server Profiler.

Note

Because of the capability to view the graphical execution plans in SQL Server Profiler as well as the capability to save the XML Showplan events to a separate file, which you can bring into SSMS for analysis, the XML Showplan events provide a significant benefit over the other, older-style showplan events provided. As a matter of fact, these other showplan events are provided primarily for backward-compatibility purposes. In a future version of SQL Server, the Showplan All, Showplan Statistics Profile, Showplan Text, and Showplan Text (Unencoded) event classes will be deprecated. It is recommended that you switch to using the newer XML event classes instead.

 
Others
 
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Technology FAQ
- Is possible to just to use a wireless router to extend wireless access to wireless access points?
- Ruby - Insert Struct to MySql
- how to find my Symantec pcAnywhere serial number
- About direct X / Open GL issue
- How to determine eclipse version?
- What SAN cert Exchange 2010 for UM, OA?
- How do I populate a SQL Express table from Excel file?
- code for express check out with Paypal.
- Problem with Templated User Control
- ShellExecute SW_HIDE
programming4us programming4us