[MarkLogic Dev General] Improving Lookup Performance

Danny Sokolsky dsokolsky at marklogic.com
Wed Oct 29 15:24:35 PST 2008


You can always use XPath to traverse around and get the nodes you want.
For example:

let $x := 
 <doc>
  <item id="12312">
    <classification name="something" />
    <term value="xyz" />
  </item>
</doc>
return
$x/item/term[../classification/@name eq "something"]

-Danny

-----Original Message-----
From: Steve [mailto:steve.a.bennett at gmail.com] 
Sent: Wednesday, October 29, 2008 9:28 AM
To: Danny Sokolsky
Subject: Re: [MarkLogic Dev General] Improving Lookup Performance

Thanks, for that. That seems to give me a bit of a performance boost.

However, it's given me a new problem. This type of predicate just
returns the node that it matches, whereas I want to be able to get
other nodes that are at the same level as the classification node.

So for example I have an xml something like:

<doc>
  <item id="12312">
    <classification name="something" />
    <term value="xyz" />
  </item>
</doc>

I want to do some sort of query that will return me the 'term' node
(and possibly the 'item') node for a given classification value. Am I
going about this the wrong way, I mean, should I be making better use
of the MarkLogic collections as my classification values??



On Wed, Oct 29, 2008 at 3:56 PM, Danny Sokolsky
<dsokolsky at marklogic.com> wrote:
> As a first step, try putting the predicate at the end of your XPath
> expression.  Something like this:
>
> fn:collection()/doc/item/classification/[@value = "class1"]
>
> Does that help?
>
> -Danny
>
> -----Original Message-----
> From: general-bounces at developer.marklogic.com
> [mailto:general-bounces at developer.marklogic.com] On Behalf Of Steve
> Sent: Wednesday, October 29, 2008 7:02 AM
> To: general at developer.marklogic.com
> Subject: [MarkLogic Dev General] Improving Lookup Performance
>
> Folks,
>
> I've got a MarkLogic instance running with approximately 100,000
> documents in it (this needs to scale to approximately 2.5 million),
> and I'm doing some basic lookups etc.
>
> I've been executing queries such as those shown below, however the
> results are taking a long time to come back. I've got indexes against
> the elements and attributes that I'm trying to lookup, however I'm
> looking for other ways to improve performance of queries. Anybody got
> any suggestions??
>
> example queries
>
> fn:collection()[/doc/item/classification/@value = "class1"]
>
> fn:colleciton()[//classification/@value = "class1"]
>
> fn:distinct-values(fn:collection()[/doc/item/name])
> _______________________________________________
> General mailing list
> General at developer.marklogic.com
> http://xqzone.com/mailman/listinfo/general
>


More information about the General mailing list