Loading TOC...

MarkLogic Server 11.0 Product Documentation
xdmp.sqlPlan

xdmp.sqlPlan(
   sql as String,
   [options as String[]]
) as ObjectNode

Summary

Returns a node representing the query plan of the given SQL SELECT query. Raises an error if the SQL query is not a SELECT query.

Parameters
sql The SQL query to be executed.
options Options as a sequence of string values. Available options are:
"optimize=N"
Sets the optimization level to use. Levels of 0 (off), 1, and 2 are recognized. The default is 1.
"xml"
Outputs an XML format query plan. This is the default.
"json"
Outputs a JSON format query plan. The default is "xml".

Required Privileges

http://marklogic.com/xdmp/privileges/xdmp-sql

Example

xdmp.sqlPlan("select  customername, customersince\n\
from customers\n\
where year(customersince)  >  2000\n\
and year(customersince)  <  2013")

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.