[MarkLogic Dev General] Improving XPath Performance
Whitby, Rob, CMG
Rob.Whitby at currentmedicinegroup.com
Wed Nov 12 06:47:59 PST 2008
If you put an attribute range index on keyword/@value you can do
something like this:
From: general-bounces at developer.marklogic.com
[mailto:general-bounces at developer.marklogic.com] On Behalf Of Steve
Sent: 12 November 2008 14:41
To: James Clippinger
Cc: General Mark Logic Developer Discussion
Subject: Re: [MarkLogic Dev General] Improving XPath Performance
I should probably add that I'm trying to extract all classification
values for the documents that have a specific keyword value.
On Wed, Nov 12, 2008 at 2:40 PM, Steve <steve.a.bennett at gmail.com>
> Thanks for your response.
> I've tried your suggestion and it doesn't really help. Looking at the
> profiling document, I can see that it's clearly the XPath on the
> document results that is slowing the who thing down. Is there any
> other ways that I can improve this. I've included a sample document
> (small), so you can see what I'm trying to achieve.
> <classification value="123" />
> <classification value="324" />
> <keyword value="word1" />
> <keyword value="word2" />
> On Wed, Nov 12, 2008 at 2:24 PM, James Clippinger
> <James.Clippinger at marklogic.com> wrote:
>> Steve, your query is doing some heavyweight filtering for the XPath
>> because it is doing two steps:
>> 1) Execute the cts:search(): generate a list of all documents
>> matching the query in relevance order.
>> 2) Execute the XPath: reorder the documents into document order and
>> find only those with /doc/classifications/classification elements,
>> returning those classification elements.
>> Since you are using XPath and thus returning results in document
>> order, you probably want to use cts:contains() in an XPath predicate
>> rather than cts:search(). cts:contains() in a rooted XPath
>> expression will use the search indexes when appropriate, so it's as
>> fast as the equivalent
>> cts:search() expression. Try this:
>> let $search := cts:element-attribute-word-query(fn:QName("",
>> "keyword"), fn:QName("", "value"), "something") return
>>> -----Original Message-----
>>> From: general-bounces at developer.marklogic.com
>>> [mailto:general-bounces at developer.marklogic.com] On Behalf Of Steve
>>> Sent: Wednesday, November 12, 2008 8:54 AM
>>> To: general at developer.marklogic.com
>>> Subject: [MarkLogic Dev General] Improving XPath Performance on
>>> I've written a query which I use to search my data set and I am able
>>> to get the results back very quickly. However the results that I get
>>> back show the complete document that the search matched, where as I
>>> want a particular node returned.
>>> At the moment I'm doing this:
>>> let $search := cts:element-attribute-word-query(fn:QName("",
>>> "keyword"), fn:QName("", "value"), "something") let $results :=
>>> return $results
>>> I've tried profiling this query and I've found that there is a big
>>> lag filtering the $results of the search using XPath.
>>> Is there any way, either through using a different query or search
>>> notation, or by indexes etc that I can speed this up.
>>> Thanks in advance...
>>> General mailing list
>>> General at developer.marklogic.com
General mailing list
General at developer.marklogic.com
More information about the General