Good point, Danny.

Within an update transaction, anything that fetches fragments will read-lock 
those fragment URIs. So doc() will, ordinarily - but inside xdmp:exists() and 
xdmp:estimate() there is no need to retrieve fragments. The behavior of 
xdmp:directory(), collection(), and cts:search() are similar, and an XPath like 
/a/b is really collection()/a/b so it behaves the same.

The various lexicon APIs don't retrieve fragments, so they take no locks: 
cts:uris, cts:values, etc. That means you shouldn't rely on their output for 
update logic. Sometimes folks assume that this makes a lexicon function 
universally faster than, say, doc() - but that is not always true. It depends 
on how much work each database lookup actually has to perform.

-- Mike

On 26 Apr 2013, at 09:23 , Danny Sokolsky <[email protected]> wrote:

> I'm sure you all know this, but just as a reminder: keep in mind that read 
> locks only happen on update transactions, so if it is a query transaction 
> that is not a factor.  
> 
> -Danny
> 
> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On Behalf Of Tim Finney
> Sent: Thursday, April 25, 2013 8:21 PM
> To: [email protected]
> Subject: Re: [MarkLogic Dev General] How to test whether doc exists
> 
> Hi Stu,
> 
> This is a good question. exists(doc) does seem to put a read lock on the doc. 
> I don't know how to find out which functions put read or update locks on a 
> doc but would like to know.
> 
> Best,
> 
> Tim
> 
> On 04/25/2013 11:10 PM, [email protected] wrote:
>> Date: Thu, 25 Apr 2013 07:44:53 -0700
>> From: Stu Salsbury<[email protected]>
>> Subject: Re: [MarkLogic Dev General] How to test whether doc exists
>> To: MarkLogic Developer Discussion<[email protected]>
>> Message-ID:
>>      <CACi3uCtTDy1VgTs8J+zH1QH_fjoKD1diH+jMbE+6_v8=pdf...@mail.gmail.com>
>> Content-Type: text/plain; charset="iso-8859-1"
>> 
>> Concerning:
>> 
>> exists(doc($URI)): 80 us (microseconds)
>> doc-available($URI): 200 us
>> 
>> Would the first option (using doc($URI)) put a read lock on the file?  
>> And the second not?  Just wondering about side effects of the test.
> 
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
> 

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

Reply via email to