I've got an old web application with a lot of legacy code and I need to improve performance for some reports. I want to avoid reports rewrite, because it's standard legacy application which is hard to maintain, test and develop. So I'm trying to speed these reports by adding indexes for reports queries in MSSQL (2008). Reports execute about 3-4k queries.
Below is my improvement plan:
1. Clean MSSQL buffers by running
DBCC DROPCLEANBUFFERS
DBCC FREEPROCCACHE
DBCC DROPCLEANBUFFERS
2. Run MSSQL profiler and then execute report.
3. Collect all report's queries and then export them to MSSQL.
4. Calculate sum of duration.
5. Group queries by textdata
and order them by sum(duration) desc
.
6. Execute queries from profiler's export and add indexes which are recommended by MSSQL Management Studio.
7. Repeat steps from 1 to 6 and compare results.
I've got interesting results. When I improve report #1 performance, report #2 performance are decreased. Also sometimes after adding indexes I've got performance decreasing tenfold.
My questions:
1. Is it a good idea to improve application performance by improving SQL queries performance?
2. Is it possible to improve performace of reports which execute 3-4k SQL queries by adding indexes?