set commands for XML format messages

You can regenerate diagnostics as an XML document. This makes it easier for front-end tools to interpret a document. You can use the native XPath query processor inside Adaptive Server to query this output if the XML option is enabled.

Either the query optimizer or the query execution layer can generate diagnostics output. To generate an XML document for the diagnostic output, use this set plan command:

set plan for
	{show_exec_xml, show_opt_xml, show_execio_xml, 
	show_lop_xml, show_managers_xml, show_log_props_xml, 
	show_parallel_xml, show_histograms_xml, show_final_plan_xml,
	show_abstract_plan_xml, show_search_engine_xml,
	show_counters_xml, show_best_plan_xml, show_pio_costing_xml, 
	show_lio_costing_xml, show_elimination_xml}
	to {client | message} on

Option

Definition

show_exec_xml

Gets the compiled plan output in XML, showing each of the query plan operators.

show_opt_xml

Gets optimizer diagnostic output, which shows the different components such as logical operators, output from the managers, some of the search engine diagnostics, and the best query plan.

show_execio_xml

Gets the plan output along with estimated and actual I/Os. show_execio_xml also includes the query text.

show_lop_xml

Gets the output logical operator tree in XML.

show_managers_xml

Shows the output of the different component managers during the preparation phase of the query optimizer.

show_log_props_xml

Shows the logical properties for a given equivalence class (one or more groups of relations in the query).

show_parallel_xml

Shows the diagnostics related to the optimizer while generating parallel query plans.

show_histograms_xml

Shows diagnostics related to histograms and the merging of histograms.

show_final_plan_xml

Gets the plan output. Does not include the estimated and actual I/Os. show_final_plan_xml includes the query text.

show_abstract_plan_xml

Shows the generated abstract plan.

show_search_engine_xml

Shows diagnostics related to the search engine.

show_counters_xml

Shows plan object construction/destruction counters.

show_best_plan_xml

Shows the best plan in XML.

show_pio_costing_xml

Shows actual physical input/output costing in XML.

show_lio_costing_xml

Shows actual logical input/output costing in XML.

show_elimination_xml

Shows partition elimination in XML.

client

When specified, output is sent to the client. By default, this is the error log. When trace flag 3604 is active, however, output is sent to the client connection.

message

When specified, output is sent to an internal message buffer.

To turn an option off, specify:

set plan for
	{show_exec_xml, show_opt_xml, show_execio_xml, show_lop_xml,
	show_managers_xml, show_log_props_xml, show_parallel_xml,
	show_histograms_xml,show_final_plan_xml
	show_abstract_plan_xml, show_search_engine_xml,
	show_counters_xml, show_best_plan_xml, show_pio_costing_xml,
	show_lio_costing_xml, show_elimination_xml} off

You need not specify the destination stream when turning the option off.

When message is specified, the client application must get the diagnostics from the buffer using a built-in function called showplan_in_xml(query_num).

query_num refers to the number of queries that are cached in the buffer. Currently, a maximum of 20 queries are cached in the buffer. The cache stops collecting query plans when it reaches 20 queries; it ignores the rest of the query plans. However, the message buffer continues to collect query plans. After 20 queries, you can display the message buffer only in its entirety by using a value of 0.

Valid values for query_num are 1 – 20, -1, and 0 (zero). A value of -1 refers to the last XML doc in the cache; a value of 0 refers to the entire message buffer.

The message buffer may overflow. If this occurs, there is no way to log all of the XML document, which may result in a partial and invalid XML document.

When the message buffer is accessed using showplan_in_xml, the buffer is emptied after execution.

You may want to use set textsize to set the maximum text size, as the XML document is printed as a text column and the document is truncated if the column is not large enough. For example, set the text size to 100000 bytes using:

set textsize 100000

When set plan is issued with off, all XML tracing is turned off if all of the trace options have been turned off. Otherwise, only specified options are turned off. Other options previously turned on are still valid and tracing continues on the specified destination stream. When you issue another set plan option, the previous options are joined with the current options, but the destination stream is switched unconditionally to a new one.