[MarkLogic Dev General] XPATH vs CTS
bhartwig at rsicms.com
Thu Jun 28 11:50:15 PDT 2012
With cts:query, you can force ML to use an index, and, of the two, may be the only way to use range indexes. That’s not to say ML isn’t trying its hardest to use the universal index when resolving an XPath expression. One issue I have with cts:query is when I use cts:element-query() with a recursive content model. It starts with the context node and searches all descendants. There isn’t an option to specify self instead of the default descendant-or-self.
From: general-bounces at developer.marklogic.com [mailto:general-bounces at developer.marklogic.com] On Behalf Of semerau at hotmail.com
Sent: Thursday, June 28, 2012 2:32 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] XPATH vs CTS
Those numbers you posted are really small so you may want to run your queries in large loops to get good averages.
If your xpath is simple then the speed is probably going to be the same as with cts. But I suppose xpath could actually be a little slower than path depending on the options you are using.
I would recommend using cts to query docs out of the db and then use xpath to get what you want within the doc. Xpath can be a performance problem if you try to get too tricky. With cts it's harder to write a poorly performing query, plus it has a lot more options than xpath
Sent from my iPhone
On Jun 28, 2012, at 12:23 PM, "Danny Sinang" <d.sinang at gmail.com<mailto:d.sinang at gmail.com>> wrote:
Can someone tell me in what situations CTS is faster than XPATH or vice versa ?
I did a little test and the results (see below) were contrary to my expectation that CTS was faster.
<v:results v:warning="more than one root item" xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:v="com.marklogic.developer.cq.view">330240 PT0.000086S</v:results>
import module namespace search = "http://marklogic.com/appservices/search"
let $query := 'assetMeta/assetType="ASSET_CONTENT_BOOK"'
let $cts-query := cts:element-query(xs:QName("assetMeta"),
cts:word-query("ASSET_CONTENT_BOOK") ) )
cts:element-value-query(xs:QName("assetType"), "ASSET_CONTENT_BOOK" ))), xdmp:elapsed-time()
<v:results v:warning="more than one root item" xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:v="com.marklogic.developer.cq.view">330240 PT0.000245S</v:results>
General mailing list
General at developer.marklogic.com<mailto:General at developer.marklogic.com>
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the General