This document discusses common SQL performance issues and how to avoid or fix them. It lists the top 5 most common SQL Server performance problems as memory pressure, query timeouts, CXPACKET wait types, expecting automatic update statistics to keep statistics updated, and TEMPDB page latch contention. It provides links to Microsoft documentation on Transact-SQL performance issues like missing indexes, patterns starting with "%" in LIKE predicates, and moving column references. It also discusses Entity Framework performance issues and tools for troubleshooting like SQLCop and using Perfmon traces.
3. Query related issues
Transact-SQL Performance Issues
http://msdn.microsoft.com/en-us/library/dd172117(v=vs.100).aspx
SR0004: Avoid using columns that do not have indexes as test expressions in IN predicates
http://msdn.microsoft.com/en-us/library/dd193249(v=vs.100).aspx
Missing indexes are the most common problem.
SR0005: Avoid using patterns that start with “%” in LIKE predicates
http://msdn.microsoft.com/en-us/library/dd193273(v=vs.100).aspx
Avoid these or use full-text indexes for these fields.
SR0006: Move a column reference to one side of a comparison operator to use a column index
http://msdn.microsoft.com/en-us/library/dd193264(v=vs.100).aspx
Do not do calculations on table column values if you can help it to avoid table scans
SR0007: Use ISNULL(column, default value) on nullable columns in expressions
http://msdn.microsoft.com/en-us/library/dd193267(v=vs.100).aspx
Always provide a default in a comparison on a nullable field, unless specifically checking for NULL.
SR0015: Extract deterministic function calls from WHERE predicates
http://msdn.microsoft.com/en-us/library/dd193285(v=vs.100).aspx
Basically calculate your variables before adding them to the WHERE clause. Think in sets and
remove extra calculations from each loop of the set. If you only run it once, then build your set it
will be a lot faster.
4. Query related issues
Chapter 14 — Improving SQL Server Performance (outdated but still
good to know)
http://msdn.microsoft.com/en-us/library/ff647793.aspx
SQL Magazine article on perf tuning
http://sqlmag.com/database-performance-tuning/troubleshooting-
common-sql-server-problems
5. SQLCop
SQLCop is a little test app. I have most of the tests as sql files so you
can run them in a CI build, or you can use the free tool from here:
http://sqlcop.lessthandot.com/
6. Entity Framework Issues
Troubleshooting Performance Problems in Entity Framework
Applications
http://sqlmag.com/entity-framework/troubleshooting-performance-
problems-entity-framework-applications
Performance Considerations for Entity Framework 4, 5, and 6
http://msdn.microsoft.com/en-us/data/hh949853.aspx
EF6 Performance Issues
http://blogs.msdn.com/b/adonet/archive/2013/10/31/ef6-
performance-issues.aspx
Use .AsNoTracking() when you are not going to update the object.
http://stackoverflow.com/questions/7403149/entity-framework-
performance-issue
7. The Top 5 Most Common SQL
Server Performance Problems
1. Memory Pressure
2. Query Timeout
Misunderstood "Timeout expired prior to the completion of..."
3. CXPACKET Wait Type
4. Expecting Auto Update Statistics to Keep Statistics Updated
5. TempDb PAGELATCH Contention
http://blogs.sqlsentry.com/jasonhall/my-perspective-the-top-5-most-
common-sql-server-performance-problems/
http://seniordba.wordpress.com/2014/07/23/5-most-common-sql-
server-performance-problems/
8. How To…
How to troubleshoot SQL Server performance issues with simple tools
(Part 1: How to collect a detailed Perfmon trace)
http://blogs.msdn.com/b/john_daskalakis/archive/2013/10/07/how-
to-troubleshoot-sql-server-performance-issues-with-simple-tools-part-
1-how-to-collect-a-detailed-perfmon-trace.aspx
How to use SQL tests in your builds with TeamCity or similar CI tools
https://www.simple-talk.com/sql/sql-tools/using-sql-test-database-
unit-testing-with-teamcity-continuous-integration/