SQL Server Query Analyzer is an interactive, graphical tool that enables a database administrator or developer to write queries, execute multiple queries simultaneously, view results, analyze the query plan, and receive assistance to improve the query performance. The Execution Plan options graphically display the data retrieval methods chosen by the Microsoft® SQL Server query optimizer. The graphical execution plan uses icons to represent the execution of specific statements and queries in SQL Server rather than the tabular representation produced by the SET SHOWPLAN_ALL or SET SHOWPLAN_TEXT statements. This is very useful for understanding the performance characteristics of a query. Additionally, SQL Server Query Analyzer shows suggestions for additional indexes and statistics on nonindexed columns that would improve the query optimizer’s ability to process a query efficiently. In particular, SQL Server Query Analyzer shows which statistics are missing, thereby forcing the query optimizer to make estimates about predicate selectivity, and then permits those missing statistics to be easily created.
The following icons displayed in the graphical execution plan represent the physical operators used by SQL Server to execute statements. For more information, see Logical and Physical Operators.
The following icons displayed in the graphical execution plan represent the cursor physical operators used by SQL Server to execute statements.
Icon | Cursor physical operator |
---|---|
Dynamic | |
Fetch Query | |
Keyset | |
Population Query | |
Refresh Query | |
Snapshot |
The graphical execution plan output in SQL Server Query Analyzer is read from right to left and from top to bottom. Each query in the batch that is analyzed is displayed, including the cost of each query as a percentage of the total cost of the batch.
Type of statement | Tree structure element |
---|---|
Transact-SQL and stored procedures | If the statement is a stored procedure or Transact-SQL statement, it becomes the root of the graphical execution plan tree structure. The stored procedure can have multiple children that represent statements called by the stored procedure. Each child is a node or branch of the tree. |
Data manipulation language (DML) | If the statement analyzed by the SQL Server query optimizer is a DML statement, such as SELECT, INSERT, DELETE, or UPDATE, the DML statement is the root of the tree. DML statements can have up to two children. The first child is the execution plan for the DML statement. The second child represents a trigger, if used in or by the statement. |
Conditional | The graphical execution plan divides conditional statements such as IF...ELSE statements (if condition exists, then do the following, else do this statement instead) into three children. The IF...ELSE statement is the root of the tree. The if condition becomes a subtree node. The then and else conditions are represented as statement blocks. WHILE and DO-UNTIL statements are represented using a similar plan. |
Relational operators | Operations performed by the query engine, such as table scans, joins, and aggregations, are represented as nodes on the tree. |
DECLARE CURSOR | The DECLARE CURSOR statement is the root of the graphical execution plan tree, with its related statement as a child or node. |
Each node displays ToolTip information when the cursor is pointed at it. The ToolTip information can include:
To create statistics
To update statistics
To delete statistics
To create a new index
To modify an index
To delete an index
SET SHOWPLAN_ALL | SET SHOWPLAN_TEXT |