You can probably see the difference in query execution by comparing the output from xdmp:plan() or the log output using cts:query-trace().
You should also mention which server release you are using. -- Mike On 12 May 2011, at 09:29 , seme...@hotmail.com wrote: > Here are some queries that are similar to the code I was talking about. > > XPath (0.04 secs) > xquery version '1.0-ml'; > let $key := "mykey" > let $lang-code := "spa" > > return > fn:collection()/resource-bundle/resource > [@key = $key] > [fn:lang($lang-code)] > > > cts (0.015 sec) > xquery version '1.0-ml'; > let $key := "mykey" > let $lang-code := "spa" > > return > cts:search(fn:collection()/resource-bundle/resource, > cts:element-attribute-value-query(xs:QName("resource"), xs:QName("key"), > $key, "exact")) > [fn:lang($lang-code)] > > The expression that takes the most time in the XPath version is "@key = > $key". What I'm curious about is just what cts does so differently that the > XPath engine doesn't, because I am noticing quite a disparity between them > given the same data and same queries effectively (which is ok, I don't have > an XPath problem, just wondering why the difference). > > -Ryan > > > > From: kelly.stir...@marklogic.com > > To: general@developer.marklogic.com > > Date: Thu, 12 May 2011 08:59:13 -0700 > > Subject: [MarkLogic Dev General] Why is cts:search so much faster than > > XPath? > > > > Equivalent XPath and cts:search expressions should perform the same. Can > > you share an example, and what version you are using? > > > > If they are equivalent and there is a performance difference, then there > > may be a bug. > > > > Kelly > > > > Message: 5 > > Date: Thu, 12 May 2011 09:05:16 -0600 > > From: "seme...@hotmail.com" <seme...@hotmail.com> > > Subject: [MarkLogic Dev General] Why is cts:search so much faster than > > XPath? > > To: <general@developer.marklogic.com> > > Message-ID: <snt121-w423bd38403eb7f1aded8d5b7...@phx.gbl> > > Content-Type: text/plain; charset="iso-8859-1" > > > > > > I wrote awhile ago that I thought it was usually best to use search:search > > for full text searching, cts:search for node selection out of the db, and > > XPath for node selection within a document. I just ran into a situation > > that doing the same query for nodes in the DB using cts:search was 6 times > > faster than using XPath. > > > > So what is it about cts:search that makes it so fast? I assume that there > > are optimizations under the covers, but how is cts:search able to gain from > > the optimizations but XPath is not? Just curious. > > > > -Ryan > > _______________________________________________ > > General mailing list > > General@developer.marklogic.com > > http://developer.marklogic.com/mailman/listinfo/general > _______________________________________________ > General mailing list > General@developer.marklogic.com > http://developer.marklogic.com/mailman/listinfo/general _______________________________________________ General mailing list General@developer.marklogic.com http://developer.marklogic.com/mailman/listinfo/general