2011-07-05Operations in the SQL Sever execution plan
This section explains the most common execution plan operations of Microsoft’s SQL Server database. You can also have a look at Microsoft’s documentation.
Index and Table Access
SQL Server has a simple terminology: “Scan” operations read the entire index or table while “Seek” operations use the B-Tree or physical address (RID, like Oracle ROWID) to access a particular part of the index or table.
- Index Seek
The
Index Seekperforms a B-Tree traversal and walks through the leaf nodes to find all matching entries. See also Chapter 1, “Anatomy of an Index”.- Index Scan
Reads the entire index—all the rows—in the index order. Depending on various system statistics, the database might perform this operation if it needs all rows in index order, e.g., because of a corresponding order by clause.
- Key Lookup (Clustered)
Retrieves a single row from a clustered index. Similar to Oracle
INDEX UNIQUE SCANfor an Index-Organized-Table (IOT). See also Chapter 5.- RID Lookup (Heap)
Retrieves a single row from a table—like Oracle
TABLE ACCESS BY INDEX ROWID. See also Chapter 1, “Anatomy of an Index”.- Table Scan
Reads the entire table—all the rows—as stored on the disk. Although multi block read operations can improve the speed of a (full) table scan dramatically it is still one of the most expensive operations at all. Besides high IO rates, a table scan must also inspect all rows from the table so that it can also put a considerable load on the CPU. See also Full Table Scan.
Join Operations
- Nested Loops
Joins two tables by fetching the result from the first table and querying the second table for each row. SQL Server uses the nested loops operation also to retrieve table data after an index access. See also “Nested Loops” in Chapter 4.
- Hash Match
The hash match join loads the candidate records from one side of the join into a hash table, which is probed for each row from the other side of the join. See also “Hash Join” in Chapter 4
- Merge Join
The merge join combines two sorted lists like a zipper. Both sides of the join must be sorted by the join predicates first. See also “Sort/Merge Join” in Chapter 4
Sorting and Grouping
- Sort
Sorts the result according to the order by clause. This operation needs large amounts of memory to materialize the intermediate result set (not pipelined). See also “Indexed Order By” in Chapter 6.
- Sort (Top N Sort)
Sorts a subset of the result according to the order by clause. Used for Top-N queries if no pipelined execution is possible. See also “Querying Top-N Rows” in Chapter 7.
- Stream Aggregate
Aggregates a presorted set according the group by clause. This operation does not buffer the intermediate result, but is executed in a pipelined manner. If this operation is, however, preceeded by a Sort, that is not executed pipelined. See also “Indexing Group By” in Chapter 6.
- Hash Match (Aggregate)
Groups the result using a hash table. This operation needs large amounts of memory to materialize the intermediate result set (not pipelined). The output is not ordered in any meaningful way. See also “Indexing Group By” in Chapter 6.
Top-N Queries
- Top
Aborts the underlying operations when the desired number of rows was fetched. See also “Querying Top-N Rows” in Chapter 7.
The efficiency of the Top-N query depends on the execution mode of the underlying operations. It is very inefficient when aborting non-pipelined operations such as
Sort.

share and subscribe
RSS FeedFlattr this! Follow me on TwitterShare at Google+Like on Facebook