Execution plan - explanation

  • Hello everyone,

    I'm trying to improve a particular query, and do some check on the Query Execution plan and see Two main Operators:

    • Index scan (Nonclustered) - Cost 39%
    • Hash Match Right outer Join - Cost 31%

    What does it actually mean, and how can I improve it?

    Thanks (:

  • Thanks for posting your issue and hopefully someone will answer soon.

    This is an automated bump to increase visibility of your question.

  • Folks will need to see the full query and execution plan before they can comment, but as with everything in SQL, "It Depends."  I'll start with your "what does it mean" question - unfortunately, less than might be hoped.  It's important to know all execution plans are estimated plans; before SQL ran your query, it thought it would be spending 39% of its effort on a Scan and another 31% on the hash match.  But if the data or statistics weren't what the query analyzer expected, those estimates could be wildly off.

    A Table Scan by itself isn't necessarily a bad thing.  If the query isn't very selective you'll usually get scans, and if there are any functions in the WHERE clause you'll likely get scans (I'm sure smart folks here can provide many other scan causes).  Sometimes these can be rewritten to get a Seek, but you shouldn't just automatically try to turn all Scans into Seeks.

    High cost percentages are also not necessarily a bad thing.  Each operator needs to take some percentage, and they all have to add up to 100, so something is always going to have a higher cost percentage than everything else.

  • These are the type of reads on the table (First) and joins (second) being made between tables. The % is the percent potion of the query these two are taking. Most of your query resources are being spent here.

    Without knowing the query and rest of the plan, it can be hard to determine what to change, or if there is anything. The query will always require 100%, so while you might shift resources to different operators, I can't tell you what will make it faster right now.

    We do have a free ebook that might help, but posting the query plan and query will help.

    https://www.sqlservercentral.com/books/sql-server-execution-plans-third-edition-by-grant-fritchey

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply