Hi Robert, The code seems to be malformed, but: Yes, it is always quicker to pre-filter node-sets, though it could be that query optimizations can rewrite things like this.
Secondly, because you are putting all lookup values in one document, the system will most likely not be able to utilize any of the indexes at all. If you would put all key-value pairs in separate documents (yes, that could generate a lot of very small documents), then it would. By the way, there is also the map:map functionality, specially for lookups, but it could be that the trade-off for initializing it at each query requires at least two or three lookups per query to make it pay off.. Hope that helps! 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 > Runstein, Robert E. (Contr) (IS) > Sent: maandag 3 augustus 2009 18:11 > To: [email protected] > Subject: [MarkLogic Dev General] Lookup Documents > > 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
