16 October 2012

SQL Server Execution Plans, Second Edition, by Grant Fritchey

Every Database Administrator, developer, report writer, and anyone else who writes T-SQL to access SQL Server data, must understand how to read and interpret execution plans. My book leads you right from the basics of capturing plans, through how to interrupt them in their various forms, graphical or XML, and then how to use the information you find there to diagnose the most common causes of poor query performance, and so optimize your SQL queries, and improve your indexing strategy.

1579-SQLServerExecutionPlans_x200.gif

Free eBook download (PDF): Download here.
Buy the printed book: $29.99

Every day, out in the various online forums devoted to SQL Server, and on Twitter, the same types of questions come up repeatedly: Why is this query running slowly? Why is SQL Server ignoring my index? Why does this query run quickly sometimes and slowly at others? My response is the same in each case: have you looked at the execution plan?

An execution plan describes what’s going on behind the scenes when SQL Server executes a query. It shows how the query optimizer joined the data from the various tables defined in the query, which indexes it used, if any, how it performed any aggregations or sorting, and much more. It also estimates the cost of all of these operations, in terms of the relative load placed on the system.

Every Database Administrator, developer, report writer, and anyone else who writes T-SQL to access SQL Server data, must understand how to read and interpret execution plans. My book leads you right from the basics of capturing plans, through how to interrupt them in their various forms, graphical or XML, and then how to use the information you find there to diagnose the most common causes of poor query performance, and so optimize your SQL queries, and improve your indexing strategy.

Keep up to date with Simple-Talk

For more articles like this delivered fortnightly, sign up to the Simple-Talk newsletter

Downloads

This post has been viewed 22832 times – thanks for reading.

  • Rate
    [Total: 26    Average: 4.7/5]
  • Share

Grant Fritchey

View all articles by Grant Fritchey

Related articles

Also in Basics

SQL Server System Functions: The Basics

Every SQL Server Database programmer needs to be familiar with the System Functions. These range from the sublime (such as @@rowcount or @@identity) to the ridiculous (IsNumeric()) Robert Sheldon provides an overview of the most commonly used of them.… Read more

Also in books

Book Review: The Phoenix Project

After hearing from Grant Fritchey that "Anyone who wants to know what DevOps really means should read this" Claire Brooking picked up a copy of The Phoenix Project. This parable of an IT project on the brink of destruction is told with humor and insight. Claire reviews the book, finding that conflict, incidents and mistakes are inevitable - what counts is how the team members grow to manage and resolve them.… Read more

Also in Database

Relational Algebra and its implications for NoSQL databases

With the rise of NoSQL databases that are exploiting aspects of SQL for querying, and are embracing full transactionality, is there a danger of the data-document model's hierarchical nature causing a fundamental conflict with relational theory? We asked our relational expert, Hugh Bin-Haad to expound a difficult area for database theorists.… Read more

Also in execution plans

Optimizing Batch Process in SQL Server

SQL Server batch processes are usually run from SQL Agent in background. They can take significant time and resources, especially if they are ETL tasks. Quite often, the responsibility for creating these tasks belongs entirely to the developer. Dennes demonstrates that DBAs can advise and assist with this type of batch job by bringing their expertise to bear on the problem of reducing their impact on the working system to a minimum.… Read more
  • dhutton27

    Sample Code
    Hello,

    Enjoying your book "Dissecting SQL Server Execution Plans" but can’t seem to find the sample code here that goes with it. I’ve searched on this web page for the book but can only find you second edition. Where might I find this.
    Thanks

    Duane

  • BlackhawkEH

    Page 23 Errata
    The level of selectivity is listed as x% on page 23. Was this intentional or is this supposed to be an actual value?

  • Grant Fritchey

    x%
    No, that’s a mistake. Sorry.

  • lesnic

    Enjoying reading the book
    I think there’s a slip on page 91:

    … joins them by scanning the outer data set (the bottom operator in a graphical execution plan)

    should read

    … joins them by scanning the outer data set (the top operator in a graphical execution plan)

  • terry.davis

    Source code
    Grant, how do I obtain the SQL source code?

  • terry.davis

    Source code
    Grant, how do I obtain the SQL source code?

  • Grant Fritchey

    Re: Source Code
    I’m pretty sure it’s somewhere here on Simple-Talk, but it looks like the link is missing. I’ll contact the guys that run the site.

  • Andrew Clarke

    Re: Source Code
    The source code is there now

  • Andrew Clarke

    Re: Source Code
    If you look at the head of the article on this page, you will see a link underneath the ‘stars’ rating, under the heading ‘Downloads’ that says ‘Source code for the book’. If you click on this, your browser should download the zip file. The source code for the book is in the zip file.
    I’ve just checked the link from the book, which is
    http://www.simple-talk.com/RedGateBooks/GrantFritchey_SQLServerExecutionPlans_Code.zip and it works fine. In fact, that is where I got the zip for the ‘download’ section of this article.

  • Grant Fritchey

    Source Control
    I just checked the link from the book. It seems to work fine. I should have checked there first.

    I see you have HTTPS instead of HTTP. I suspect that might be the problem you were hitting. The book doesn’t list either.

Join Simple Talk

Join over 200,000 Microsoft professionals, and get full, free access to technical articles, our twice-monthly Simple Talk newsletter, and free SQL tools.

Sign up