An efficient way is to use fn:subsequence instead of a predicate. -m On Jun 22, 2012, at 2:00 PM, Damon Feldman wrote:
Danny, Try subsequence($pageSessionLogs, count($pageSessionLogs), 1) Anything in square brackets is evaluated once for each element of the sequence, so if you profile that you’ll see something like “postion()=last()” evaluated many times – it just looks like an array index due to a syntactic sugar. Yours, Damon From: [email protected]<mailto:[email protected]> [mailto:[email protected]] On Behalf Of Danny Sinang Sent: Friday, June 22, 2012 4:24 PM To: general Subject: [MarkLogic Dev General] Faster alternative to fn:last() Hello, I'm trying to get the first and last documents in a sequence. The code goes like this : let $firstLog := $pageSessionLogs[1] let $lastLog := $pageSessionLogs[fn:last()] After doing some timings, it looks like the 2nd line always takes around 30 milliseconds. And since I'm doing this in a loop, the delays add up significantly. Is there a faster way of getting the last sequence member ? Regards, Danny _______________________________________________ General mailing list [email protected]<mailto:[email protected]> http://community.marklogic.com/mailman/listinfo/general
_______________________________________________ General mailing list [email protected] http://community.marklogic.com/mailman/listinfo/general
