Question

I have a query that is running slowly. I know generally to make performance faster, limit joins, and try to use procs instead of straight queries. Due to business rules, I cannot use procs. I've already cut the number of joins as much as I can think of.

What's the next step in query tuning?

Was it helpful?

Solution

the easiest thing to do is go to management studio run this command:

SET SHOWPLAN_ALL ON

then run your actual query.

You will not get your regular query result set. It will give you the execution plan (a very detailed list of what SQL Server does to turn your query) in a result set. Look over the output and try to learn what it means. I generally look for "SCAN", that is a slow part, and I try rewriting it so it uses an index.

OTHER TIPS

Adding indexes is probably the number one thing you can do to improve query performance and you haven't mentioned it.

Have you looked at the execution plan to see whether that could be improved with additional indexes?

Additionally you should make sure that your queries are written in such a way so they can use any indexes that are present effectively (e.g. avoid non sargable constructs, avoid *)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top