thanks, I actually do use eq not = ... 

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Micah
Dubinko
Sent: Tuesday, November 10, 2009 6:41 PM
To: General Mark Logic Developer Discussion
Subject: Re: [MarkLogic Dev General] Optimize exact match searches
onattributes

David,

I'm guessing the optimizer already does this, but just in case, try  
using the atomic comparison operator eq instead of =. (The value in  
$code will never be a sequence, right?)

> $root/tree/item[ @code eq $code ]

Even though it goes against conventional wisdom, also try $root//item 
[ ... ]

You can use xdmp:elapsed-time() to get decent resolution timing data  
to experiment with what works the fastest.

-m

On Nov 10, 2009, at 3:15 PM, Lee, David wrote:

> Suppose I have an XML document with about 50,000 of these small  
> elements
>    <item name="Peritoneum" parent="A01.047.025"  
> code="A01.047.025.600"/>
>
> And an Xquery that does a LOT of this kind of search
>
>             let $item = $root/tree/item[ @code = $code ]
> or
>             let $item = $root/tree/item[ @parent  = $code ]
>
>
> These are exact string matches, no fancy terming or wildcards or  
> anything.
>
> Any suggestions on the basic area to look for optimizing this kind  
> of access ? Either using xquery or a setting on the server ?
> Thanks for any suggestions.  So far I've only been able to find  
> things tailored for full text searching (1 letter, 2 letter, word  
> searches etc).
> I would think direct attribute=value searches could be tagged for  
> efficient indexing.  Maybe they are already ?
> But its starting to slow down when I do about 20 of these in an  
> xquery.
>
> One thought I had was to preprocess the data into more of a tree  
> structure instead of the flat structure it is now ...
>    <item >
>      <item>
>        <item>
>    </item>
>   </item>
>
> then I can use ancestor axis to search up the tree instead of a flat  
> search ... But if these were already indexed it "should" be a near  
> instant access as a flat structure (???)
>
>
>
> ----------------------------------------
> David A. Lee
> Senior Principal Software Engineer
> Epocrates, Inc.
> [email protected]
> 812-482-5224
>
>
> _______________________________________________
> General mailing list
> [email protected]
> http://xqzone.com/mailman/listinfo/general

_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to