One of the final tasks I undertake with all applications I
develop is to run SQL Server Profiler on the database to look for
any potential opportunities to optimise my stored procedures or
indexes.
For those who have never used SQL Server Profiler before it is
actually very easy to use and is one of the most helpful tools you
will come across. To give you a brief overview of the tool
the first thing you do is start a new 'Trace' session. What
this entails is selecting the database you want to profile and then
selecting the type of events you want to record (SQL Statement
executing, stored procedure executing etc...). You can then
start the trace and go about using your application as normal.
After you have finished playing with your application you can
stop the 'trace', and all the trace data will be saved to a file or
database table (you can choose when you setup the trace).
Now that you have the usage data you can look through the list
for any queries which are taking a long time to run. Once I
identify the longest running queries I first look at the stored
procedures to see if there is anyway I can optimise them.
After that you can then run the 'Performance Tuning' function of
SQL Server Profiler and feed in the trace file you created.
Profiler will then analyse the workload and automatically
suggest new indexes which will improve your systems
performance.
All up the process of setting up a trace, running it and
analysing the results usually takes less than 30 minutes and can
result in huge improvements to your applications speed.
For further information on using SQL Server Profiler, please
check the link below: