SQL Profiler Works in Sql Server

 

How to determine what queries need indexing?

  • WAY 1: By Create trace
  • WAY 2: Using SQL Profiler

 

Using SQL Profiler- Primary purpose of SQL profiler is to capture all activity based against the SQL database, SQL Server itself.

 

 

Right down you queries on new query window that want to TRANCE

 

 

 

Activate SQL Profiler

Connect window will appear, connect it

  • Trace Property window appear
    • Go to Event selection tab and uncheck most of the options except following
      • TextData
      • ApplicationName
      • SPID
    • Click show all columns checkbox
      • and choose all checkbox of Database name Column
      • uncheck all columns checkbox. Our final out come like below
    • Click Column filters button will open a popup and filter by database name
      • To run Traces only for this database, rather than running against every single database 
  • Run to record your Traces 
    • Click Run Button

 

 

Execute you above Queries

  • Run Execute in your Query Window. No SQL Profiler will trace query in query window 

 

 

WHY Traces

Run it and the trace has begun, meaning it's ready to detect anything that connects to it and any SQL queries

 

Once everything traced, click stop trace button 

Click on specific trance to see trace detail in bottom section

Save your Traces for later Use

  • D:\NotesCollections

 


Check Traces and Determine what queries need indexing?

Open Tuning Advisor in SQL Profiler

  • Connect your SQL Server
  • Open your saved Trace file above
  • Select file and your database
  • Click button “Start Analysis

 

Basically, it's going to go through that entire file and look at each queries and look at look at each queries and determine and recommend if any of those queries need to be created.

 

Show you Recommendations

 

 

Check recommendations by clicking the link

 

 

We can apply this recommendations 

 

We can either apply these recommendations or save for later usage

 


Related Question