I am having a hard time finding details about what the output of xdmp:plan
means.
Having a simple query like this:
xdmp:plan(cts:search(doc(), cts:element-value-query(xs:QName("description"), "some text")))
results in quite a long execution plan:
<qry:query-plan xmlns:qry="http://marklogic.com/cts/query">
<qry:expr-trace>...</qry:expr-trace>
...
<qry:partial-plan>
<qry:term-query weight="1">
<qry:key>16037778974159125508</qry:key>
<qry:annotation>element(description,value("some","text"))</qry:annotation>
</qry:term-query>
</qry:partial-plan>
...
<qry:ordering></qry:ordering>
<qry:final-plan>
<qry:and-query>
<qry:term-query weight="1">
<qry:key>16037778974159125508</qry:key>
<qry:annotation>element(description,value("some","text"))</qry:annotation>
</qry:term-query>
</qry:and-query>
</qry:final-plan>
<qry:info-trace>Selected 0 fragments to filter</qry:info-trace>
<qry:result estimate="0"></qry:result>
</qry:query-plan>
The only part of the documentation mentioning xdmp:plan
is its documentation itself. Other than that i can not find anything else. I'd like some details about what e.g. qry:key
or qry:annotation
really mean.
Is there any documentation i am missing describing the possible output of xdmp:plan
. As this is a really valuable tool in order to understand query performance, i expected it to be rather well documented.
Edit: This marklogic blog post i found gives some examples of how a query plan can be interpreted.
Still, i feel like a blog post should not be the only reasonable documentation for this tool.
Some questions still on my mind:
- Whats the difference between a
partial-plan
and afinal-plan
. Is afinal-plan
a merge of allpartial-plans
? For what and when is apartial-plan
used? Partial-plans seem to contribute constraints. Are these constraints used at index resolution stage to find candidate fragment ids? What role does afinal-plan
play there? Is afinal-plan
used to filter out false-positives after the index resolution ?
Sometimes i can find this in the query plan:
<qry:elem-word-trace text="computer" elem-name="title" elem-uri="">
<qry:key>10975994818398622042</qry:key>
</qry:elem-word-trace>
- What does a
qry:elem-word-trace
mean? - What about
<qry:ordering></qry:ordering>
? Added a simple description about ordering to my answer. - A simple xpath query like
/doc[id = 1]
outputs the following 2 times:
Is there a reason for that ? Why does step 2 predicate 1 contribute the same partial-plan
twice?
<qry:info-trace>Step 2 predicate 1 contributed 1 constraint: id = 1</qry:info-trace>
<qry:partial-plan xmlns:qry="...">...</qry:partial-plan>
<qry:info-trace>Step 2 predicate 1 contributed 1 constraint: id = 1</qry:info-trace>
<qry:partial-plan xmlns:qry="...">...</qry:partial-plan>