Hi Pragya, You have both mem-updates, and xdmp:save inside the loop. So first of all, it is doing a save for each iteration through the loop. Secondly, doing that many mem-updates is a performance killer.
Move xdmp:save after the for-loops by doing something like: let $_ := for …. return … return xdmp:save(…) And instead of using those mem-update functions, you could consider using this lib instead: http://github-search.demo.marklogic.com/detail/ryanjdew/XQuery-XML-Memory-Operations.json With that you build up a queue of edits first, and then run through them all at once. Cheers, Geert From: <general-boun...@developer.marklogic.com<mailto:general-boun...@developer.marklogic.com>> on behalf of "Kapoor, Pragya" <pkapo...@innodata.com<mailto:pkapo...@innodata.com>> Reply-To: MarkLogic Developer Discussion <general@developer.marklogic.com<mailto:general@developer.marklogic.com>> Date: Thursday, July 14, 2016 at 8:53 AM To: MarkLogic Developer Discussion <general@developer.marklogic.com<mailto:general@developer.marklogic.com>> Subject: [MarkLogic Dev General] XDMP-EXTIME errror Use Case: We need to merge two XML files based on common element ID. DocList.xml with size of 31 MB and other DocListExtra.xml of 8MB The xquery code is giving Time Limit exceed error. Code: import module namespace mem = "http://xqdev.com/in-mem-update" at "/rest-apis/utils/mem.xqy"; let $docList := fn:doc("/misc/DocList.xml") let $extraList := fn:doc("/misc/DocListExtra.xml") let $docExtra := let $docIDs := $docList//ID/text() for $doc in $extraList return $doc//DocumentExtra[./DocumentExtraID/text() = $docIDs] for $doc in $docList for $each in $docExtra let $x := $doc//Document[./ID/text() = $each/DocumentExtraID/text()] let $dummy := mem:node-insert-child($x,$each//CustomMetadata) return xdmp:save("/data/merged.xml",$dummy) Please suggest. Thanks Pragya "This e-mail and any attachments transmitted with it are for the sole use of the intended recipient(s) and may contain confidential , proprietary or privileged information. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this e-mail or any action taken in reliance on this e-mail is strictly prohibited and may be unlawful."
_______________________________________________ General mailing list General@developer.marklogic.com Manage your subscription at: http://developer.marklogic.com/mailman/listinfo/general