You can use the Query Profiler tool to debug, troubleshoot, monitor, and measure your application SQL statements and stored procedures. If your application has a performance problem that you think might be caused by a particularly long-running query, you can analyze query durations.
In this topic, we will review how to profile a simple query. As an example,we will use the AdventureWorks2012 test database from Microsoft.
We are going to select all persons from the Person table where the first name is “Robin”.
In the text editor, type the following script:
SELECT * FROM AdventureWorks2012.Person.Person WHERE FirstName = 'Robin'
Click Execute. The Plan Diagram window opens.
Note that the select icon contains the exclamation mark icon that warns about a shortcoming. A tooltip appears automatically when you pause the mouse pointer over the select icon. The bottom part of the tooltip contains the warning message that tell us that the index is missing.
To add the index:
Click Update Database.
Now, we can get back to the Query Profiler and click the Get New Results button.
Each time you get profiling results for the executed query, they appear in the tree view as a new node with time and date of query execution. When editing your query, you want to know whether your changes reduce query execution time or not. Query Profiler can quickly compare the profiling results. To compare results, hold the CTRL key and select both plan diagrams.
When you save the query file after getting the query profiling results, the latter will be automatically stored in the .design file.