Returns query plans in an HTML format string.
HTML_PLAN ( string-expression )
Parameter | Description |
---|---|
string-expression |
SQL statement for which the plan is to be generated. It is primarily a SELECT statement but can be an UPDATE or DELETE statement. |
No plan available
The behavior of the HTML_PLAN function is controlled by database options QUERY_PLAN_TEXT_ACCESS and QUERY_PLAN_TEXT_CACHING. If QUERY_PLAN_TEXT_ACCESS is OFF (the default), this message appears:
Plan not available. The database option QUERY_PLAN_TEXT_ACCESS is OFF
If QUERY_PLAN_TEXT_ACCESS is ON, and the query plan for the string expression is available in the cache maintained on the server, the query plan from the cache is returned to you.
See Reference: Statements and Options > Database Options > Alphabetical List of Options > QUERY_PLAN_TEXT_ACCESS Option. See Reference: Statements and Options > Database Options > Alphabetical List of Options > QUERY_PLAN_TEXT_CACHING Option.
The HTML_PLAN function can be used to return query plans to Interactive SQL using SELECT, UPDATE, DELETE, INSERT SELECT, and SELECT INTO.
Users can view the query plan for cursors opened for Sybase IQ queries. To obtain the query plan for the most recently opened cursor, use:
SELECT HTML_PLAN ( );
With QUERY_PLAN_AFTER_RUN option OFF, the plan appears after OPEN CURSOR or CLOSE CURSOR. However, if QUERY_PLAN_AFTER_RUN is ON, CLOSE CURSOR must be executed before you request the plan.
See Reference: Statements and Options > Database Options > Alphabetical List of Options > QUERY_PLAN_AFTER_RUN Option.
For information on viewing the query optimizer's execution plan for a SQL statement in the Plan Viewer window in Interactive SQL, see SQL Anywhere Server - Database Administration > Administering your database > SQL Anywhere graphical administration tools > Using Interactive SQL > Using the Plan Viewer to view graphical plans.
When you request an HTML_PLAN for a SQL Anywhere query or for an OMNI/CIS decomposed query, the following message is returned:
No plan. HTML_PLAN function is not supported for this type of statement or database.
SELECT HTML_PLAN ('SELECT * FROM Employees'); OUTPUT to 'C:\hplan.html' HEXADECIMAL ASIS QUOTE '';
The OUTPUT TO clause HEXADECIMAL ASIS is useful for text that contains formatting characters such as tabs or carriage returns. When set to ASIS, values are written as is, without any escaping, even if the values contain control characters.
The following example returns the HTML query plan from the cache, if available.
SELECT HTML_PLAN ( );