In theory xdmp:exists(doc($uri)) is fastest. However it isn't update-safe 
because it doesn't take a read lock. If you are writing update logic that 
depends on whether or not a document exists, stick with fn:exists(doc($uri)).

Speed of either will depend on many factors: whether or not the document is in 
cache, disk performance, database size, cluster configuration, etc.

-- Mike

On 24 Apr 2013, at 20:36 , Tim Finney <[email protected]> wrote:

> Hi All,
> 
> What is the fastest way to test for existence of a document in the 
> database?
> 
> This is the fastest way I know:
> 
> let $URI := "/path/to/doc.xml"
> return exists(doc($URI))
> 
> It takes about 75 us (microseconds) to return an answer according to the 
> profile tab of qconsole.
> 
> Best,
> 
> Tim Finney
> _______________________________________________
> 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