<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"><meta name="Generator" content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.E-mailStijl17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style></head><body lang="NL" link="blue" vlink="purple"><div class="WordSection1"><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">Hi Danny,</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"> </span></p><p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">Performance should be easy to measure. Call the function from within QConsole x number of time and request profile output. Do the same while using xdmp:exists instead of fn:exists. That function works only on (partially) searchable expression, because it doesn’t retrieve the actual content. It won’t create a read-lock either, but I’m not sure why you want one. It won’t prevent duplicate id’s from being generated in concurrent requests..</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"> </span></p><p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">Kind regards,</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">Geert</span></p><p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"> </span></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">Van:</span></b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;"> <a href="mailto:general-bounces@developer.marklogic.com">general-bounces@developer.marklogic.com</a> [mailto:<a href="mailto:general-bounces@developer.marklogic.com">general-bounces@developer.marklogic.com</a>] <b>Namens </b>Danny Sinang<br>
<b>Verzonden:</b> woensdag 29 augustus 2012 19:11<br><b>Aan:</b> general<br><b>Onderwerp:</b> [MarkLogic Dev General] Performance of fn:exists(fn:doc($uri))</span></p><p class="MsoNormal"> </p><p class="MsoNormal">Hi,</p>
<div><p class="MsoNormal"> </p></div><div><p class="MsoNormal">ML support suggested we do this to generate a unique ID for our documents :</p></div><div><p class="MsoNormal"> </p></div><blockquote style="margin-left:30.0pt;margin-right:0cm">
<p class="MsoNormal"><span style="font-size:13.5pt;font-family:&quot;Courier New&quot;;background:white">declare function choose-uri() as xs:string</span><span style="font-size:13.5pt;font-family:&quot;Courier New&quot;"><br>
<span style="background:white">    {</span><br><span style="background:white">       let $uri := fn:concat(&quot;/document-&quot;, xdmp:random(), &quot;.xml&quot;)</span><br><span style="background:white">       return if (fn:exists(fn:doc($uri))) then choose-uri() else $uri</span><br>
<span style="background:white">    };</span></span> </p></blockquote><div><p class="MsoNormal"> </p></div><div><p class="MsoNormal">My question is, will the call to fn:exists(fn:doc($uri)) be fast, considering that we now have 8 million documents ?</p>
</div><div><p class="MsoNormal"> </p></div><div><p class="MsoNormal">The fn:exists(fn:doc($uri)) call is needed to obtain a read lock, which will be upgraded to a write lock when xdmp:document-insert is called.</p></div><div>
<p class="MsoNormal"> </p></div><div><p class="MsoNormal">Regards,</p></div><div><p class="MsoNormal">Danny</p></div><div><p class="MsoNormal"> </p></div><div><p class="MsoNormal"> </p></div></div></body></html>