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

Reply via email to