In this section, We focus on how to create Index for Table and how much percentage this index increase the performance.
SQL Server Profiler
- Open SQL Server Management Studio and connect the Database Server.
- To open SQL Profiler, Choose Tools --> SQL Server Profiler
Open SQL Server Profiler through Management Studio - New the SQL Server Profile will open, then Connect to Database Server.
SQL Server Profiler - Now the Trace Property Window will open.
SQL Profiler Trace Properties Window - Choose the "Use the template:" as "Tuning".
Profiler Tuning Template - Click on the Tab "Events Selection".
Tuning Template - Events Selection - Click on "Column Filters.." button. Now "Edit Filter" Popup window will open.
Profiler - Event Selection - Edit Filter - Now Click on "Database" and Expand the Like & Then specify the Database Name.
- Then click "OK" button to close the "Edit Filter" Popup window.
- Now click on "Run" button.
- Execute the SQL Query or SP which want to optimize in "SQL Server Management Studio".
- Now check the SQL Server Profiler, the executed Query are logged in the Trace Window.
SQL Profiler Window - Now click on the "Stop" icon to stop the trace.
Stop Trace - Now save the Trace log as "Trace File". For that, choose File --> Save As --> Trace File..
Save as Trace File - Now "Save As" window will open, Type the file and confirm the "SQL Server Profiler trace files (*.trc)" and click on "Save" button.
Database Engine Tuning Advisor
- To open "Database Engine Tuning Advisor", In "SQL Server Profiler" choose Tools -> Database Engine Tuning Advisor..
Tuning Advisor from Profiler - Now the "Database Engine Tuning Advisor" will open.
Database Engine Tuning Advisor - For that, Check "File" radio option under "Workload" section.
- Now Click on "Browse" icon and choose the ".trc" SQL Server Profiler trace file. Then select the required Databases.
choose SQL Server Profiler trace file - Now Click on the "Start Analysis".
Start Analysis - Now the query will start analyzing, In the "Recommendations" tab, it will show the indexes which need to create & also show the "Estimated Improvements" in percentage at the top.
Recommendations - Now click on the "Definition" column to view the create Index query.
- View the query and execute it.
No comments:
Post a Comment