If you haven’t found it yet, you can use xdmp:elapsed-time() (see 
https://docs.marklogic.com/xdmp:elapsed-time) to return the elapsed time 
without the query meters overhead. fn:current-dateTime() returns the same value 
throughout the execution of a statement.

-James

From: <general-boun...@developer.marklogic.com> on behalf of sweet frd 
<sumathisumi...@gmail.com>
Reply-To: MarkLogic Developer Discussion <general@developer.marklogic.com>
Date: Wednesday, October 12, 2016 at 5:21 AM
To: MarkLogic Developer Discussion <general@developer.marklogic.com>
Subject: Re: [MarkLogic Dev General] xdmp:query-meters performance and use

Thanks Jason!

We are trying to tune an xquery for better performance and that particular 
xquery uses xdmp:query-meters to calculate the elapsed time from one line to 
another, when we replace xdmp:query-meters() with fn:current-dateTime() and 
subtract it instead, we could save a couple of 100 milliseconds but there seems 
to be a difference in elapsed time values when compared with each other. Is 
using fn:currentdateTime() for elapsed time and xdmp:query-meters the same? 
what is the ideal way to calcaulate the elapsed time without compromising the 
performance of the xquery. Thanks in advance

Regards,
N. Sumathi

On Tue, Oct 11, 2016 at 4:19 AM, Jason Hunter 
<jason.hun...@marklogic.com<mailto:jason.hun...@marklogic.com>> wrote:
You'll notice the time of xdmp:query-meters() is 1 millisecond.  It's pretty 
fast already.  :)

The time of cts:uri-match("*") is 0 milliseconds.  Amazing, right?  That's 
because MarkLogic is intelligently "lazy" and didn't actually do the work 
because you never checked the results.

Change it to count(cts:uri-match("*")) to force it to execute, and then you'll 
get more interesting timing data.  (BTW, you can use cts:uris() if you really 
want to match all.)

-jh-


On Oct 11, 2016, at 16:02, sweet frd 
<sumathisumi...@gmail.com<mailto:sumathisumi...@gmail.com>> wrote:

Hi,

In my xquery, i have used the xdmp:query-meters and it seems that line has 
taken more time to process than any other line while doing profile.

Example :
Query : cts:uri-match("*"), xdmp:query-meters()
PFA for profile result.

The shallow and deep time is more for the xdmp:query-meters(). How to avoid 
this and is there any other way i can get the same functionality of 
xdmp:query-meters() which will take less time?

Also, can anyone explain when and why we go for xdmp:query-meters with a simple 
example.
<profile_capture.PNG>_______________________________________________
General mailing list
General@developer.marklogic.com<mailto:General@developer.marklogic.com>
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general


_______________________________________________
General mailing list
General@developer.marklogic.com<mailto:General@developer.marklogic.com>
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general

_______________________________________________
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to