Here what can be done during a session of SQL performance tuning.
Slow store procedure. This query was running for a long time, causing a blocking chain and High CPU usage.
What was done
Added these two new indexes:
As expected, the same output (result set) was presented by the original and modified query.
The first spreadsheet shows the original version of the store procedure (red). The next is the version tuned by red9 (green).
Tuning results vary. They vary based on the complexity of the query, how much tuning has gone into it already, etc. But we rarely can’t make T-SQL perform faster.
Indexes operate “behind the scenes”: adding and removing indexes rarely changes an application’s code.
The SQL Server engine uses an index, as a reader uses a book index. Without it, the reader needs to look at every page in a book to find a word.
Indexes are the method by which SQL Server sorts and organizes the rows in tables. It allows you to quickly narrow in on the rows to satisfy the query and avoid scanning every row in the table.
In database terms, a table scan (or just scan) happens when there is no index available to help a query. They have a terrific impact on performance on large tables, but sometimes are inevitable.
The proper index can drastically increase the performance of an application. However, there are tradeoffs to almost any feature, and indexes are no exception.
We tune slow SQL Servers every day. For over a DECADE now. Contact us!