Common SQL Performance Issues

SQL Performance

Common SQL Performance Issues

Created 3 years ago

Duration 0:00:00
lesson view count 52
Select the file type you wish to download
Slide Content
  1. Common SQL Performance  Issues

    Slide 1 - Common SQL Performance Issues

    • And how to Avoid or fix them
  2. Common SQL Performance Issues

    Slide 2 - Common SQL Performance Issues

    • End users writing poor queries
    • Power users writing poor queries
    • Junior developers writing poor queries
    • Senior developers writing poor queries
    • Software architects writing poor queries.
  3. Query related issues

    Slide 3 - Query related issues

    • Transact-SQL Performance Issues
    • SR0004: Avoid using columns that do not have indexes as test expressions in IN predicates indexes are the most common problem.
    • SR0005: Avoid using patterns that start with “%” in LIKE predicates 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 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 provide a default in a comparison on a nullable field, unless specifically checking for NULL.
    • SR0015: Extract deterministic function calls from WHERE predicates 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

    Slide 4 - Query related issues

    • Chapter 14 — Improving SQL Server Performance (outdated but still good to know)
    • SQL Magazine article on perf tuning
  5. SQLCop

    Slide 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:
  6. Entity Framework Issues

    Slide 6 - Entity Framework Issues

    • Troubleshooting Performance Problems in Entity Framework Applications
    • Performance Considerations for Entity Framework 4, 5, and 6
    • EF6 Performance Issues
    • Use .AsNoTracking() when you are not going to update the object.
  7. The Top 5 Most Common SQL Server Performance Problems

    Slide 7 - The Top 5 Most Common SQL Server Performance Problems

    • Memory Pressure
    • Query TimeoutMisunderstood "Timeout expired prior to the completion of..."
    • CXPACKET Wait Type
    • Expecting Auto Update Statistics to Keep Statistics Updated
    • TempDb PAGELATCH Contention
  8. How To…

    Slide 8 - How To…

    • How to troubleshoot SQL Server performance issues with simple tools (Part 1: How to collect a detailed Perfmon trace)
    • How to use SQL tests in your builds with TeamCity or similar CI tools