Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.
Returns the optimization strategy of a SQL statement as a plain text string.
[ , cursor-type ]
[, update-status ]
The SQL statement, which is commonly a SELECT statement, but can also be an UPDATE, MERGE, or DELETE statement.
A cursor type, expressed as a string. Possible values are asensitive, insensitive, sensitive, or keyset-driven. If cursor-type is not specified, asensitive is used by default.
A string parameter accepting one of the following values indicating how the optimizer should treat the given cursor:
The statement's access plan is returned as a string. For information about interpreting the result, see Advanced: Query execution plans.
The GRAPHICAL_PLAN function offers significantly greater information about access plans, including system properties that
may have affected how the statement was optimized.
This information can help you decide which indexes to add or how to structure your database for better performance.
The following statement passes a SELECT statement as a string parameter and returns the plan for executing the query:
SELECT EXPLANATION( 'SELECT * FROM Departments WHERE DepartmentID > 100' );
The following statement returns a string containing the short form of the text plan for an INSENSITIVE cursor over the query
'select * from Departments where ....':
SELECT EXPLANATION( 'SELECT * FROM GROUPO.Departments WHERE DepartmentID > 100',
'insensitive', 'read-only' );