Lots of interesting suggestions. :-) I can imagine that the best choice depends on conditions like the number of lookup values. Hard-coded values will have size limits, depending on (tree cache) memory settings? How many values can be loaded in a map:map before its performance starts to decay? And how sensible is utilizing an index by putting each key-value in a separate doc?
As always eager to learn. Kind regards, Geert > Drs. G.P.H. Josten Consultant http://www.daidalos.nl/ Daidalos BV Source of Innovation Hoekeindsehof 1-4 2665 JZ Bleiswijk Tel.: +31 (0) 10 850 1200 Fax: +31 (0) 10 850 1199 http://www.daidalos.nl/ KvK 27164984 De informatie - verzonden in of met dit emailbericht - is afkomstig van Daidalos BV en is uitsluitend bestemd voor de geadresseerde. Indien u dit bericht onbedoeld hebt ontvangen, verzoeken wij u het te verwijderen. Aan dit bericht kunnen geen rechten worden ontleend. > From: [email protected] > [mailto:[email protected]] On Behalf Of > Kelly Stirman > Sent: maandag 3 augustus 2009 21:34 > To: [email protected] > Subject: [MarkLogic Dev General] RE: Lookup Documents > > Bob, > > Another option - you could store your lookup values in your > xquery module. Because static xml is valid XQuery, you could > do something like the following: > > declare function local:vals() as node(){ <config> > <entry id="1">foo</entry> > </config> > }; > > local:vals() > > Another option is to use a variable: > > declare variable $local:vals as node() := <config> > <entry id="1">foo</entry> > </config>; > > $local:vals > > We frequently employ one of these two patterns. You might > take a look at the code generated by ApplicationBuilder to > see them at work. > > In either of these cases, the static values stored in the > XQuery modules are loaded into cache with the rest of the > program. The performance difference may be quite small > depending on your application, but I believe in your XQuery > module is the most efficient. > > Also, if you're storing values in a document, then it can be > a little tricky to perform an fn:doc() on your configuration > information if it isn't stored with the contents of your > database, and you may not want your config information > comingled with your content. On the downside, there's not an > easy way to update the static XML in an XQuery file, so if > you have frequent updates, you may wish to have an XML > document, which makes updates easier. > > Kelly > > > Message: 1 > Date: Mon, 3 Aug 2009 11:11:09 -0500 > From: "Runstein, Robert E. (Contr) (IS)" <[email protected]> > Subject: [MarkLogic Dev General] Lookup Documents > To: <[email protected]> > Message-ID: > > <[email protected]> > Content-Type: text/plain; charset="us-ascii" > > Hi, > > I have a document that is contains lookup values that are > frequently accessed. > > When a new document is ingested, I loop through its keys and > pull the matching values from the lookup document. > > Is there a difference in performance between this code: > > let $lookups := fn:doc($lookup-uri)//values return for $key > in $keys return $value := $lookups[key = $key] > > And this code? > > for $key in $keys > return $value := fn:doc($lookup-uri)//values[key = $key] > > Am I correct in thinking that the former is reading in all > the values (some of which may not be used), while the latter > just pulls back the values that are needed? > > Bob > _______________________________________________ > General mailing list > [email protected] > http://xqzone.com/mailman/listinfo/general > _______________________________________________ General mailing list [email protected] http://xqzone.com/mailman/listinfo/general
