That matches my experience: I can generally get some performance improvement by 
porting XSLT work to XQuery. However I'd start by choosing the right tool for 
the job, and getting the data model and processing model right. Then you can do 
any optimization work as you see performance problems.

I tend to keep as much code as possible in XQuery libraries, because I can call 
those functions from XSLT or XQuery. That makes it easier to move functionality 
between XQuery and XSLT. It also makes it easier to write tests.

In case anyone's interested here's a micro-benchmark, with timings using 7.0-4 
and my laptop. This expects certain element names and rewrites them in 
lower-case form.

xquery version "1.0-ml";
xdmp:xslt-eval(
<xsl:stylesheet
xmlns:xs="http://www.w3.org/2001/XMLSchema";
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="2.0">
 <xsl:template match="ROOT">
   <xsl:element name="root">
     <xsl:apply-templates select="@*|node()"/>
   </xsl:element>
 </xsl:template>
 <xsl:template match="TEST">
   <xsl:element name="test">
     <xsl:apply-templates select="@*|node()"/>
   </xsl:element>
 </xsl:template>
</xsl:stylesheet>,
  document {
    element ROOT { (1 to 100 * 1000) ! <TEST/> } },
  ())
! xdmp:describe(.)
, xdmp:elapsed-time()

=>
document{<root 
xmlns:xs="http://www.w3.org/2001/XMLSchema";><test/><test/><test/><test/><test/><test/><test/><test/><test/><...</root>}
PT1.199259S

xquery version "1.0-ml";
declare function local:do($n as node())
as node()?
{
  typeswitch($n)
  case document-node() return document { local:do($n/node()) }
  case element(ROOT) return element root { $n/@*, local:do($n/node()) }
  case element(TEST) return element test { $n/@*, local:do($n/node()) }
  default return $n
};

local:do(
  document {
    element ROOT { (1 to 100 * 1000) ! <TEST/> } })
! xdmp:describe(.)
, xdmp:elapsed-time()

=>
document{<root><test/><test/><test/><test/><test/><test/><test/><test/><test/><...</root>}
PT0.375941S

Because this is such a simple test it probably exaggerates the differences vs 
real-world code. Also there may be opportunities to optimize both 
implementations. I tried to write each in a straightforward way, and the 
profiler shows about 60k expressions each way. The XQuery version does some 
pruning that I don't know how to do in XSLT. That accounts for about 10k 
expressions and 50-100 ms.

-- Mike

> On 11 Nov 2014, at 06:23 , Mary Holstege <[email protected]> wrote:
> 
> I would expect performance to be similar or favor XQuery. A lot of the 
> underlying implementation is shared, and where it is not, the XQuery has a 
> lot more person years of optimization work behind it.
> 
> //Mary
> 
> On Nov 11, 2014 4:39 AM, [email protected] wrote:
> Hi All, 
> 
> We are using XQuery to transform big payload from one to another format 
> (Change in structure and some filtering). Does any one have experience in 
> significant performance improvement when switching from XQuery to XSLT in 
> MarkLogic server.
> 
> Thanks
> Abhishek
> This e-mail and any files transmitted with it are for the sole use of the 
> intended recipient(s) and may contain confidential and privileged 
> information. If you are not the intended recipient(s), please reply to the 
> sender and destroy all copies of the original message. Any unauthorized 
> review, use, disclosure, dissemination, forwarding, printing or copying of 
> this email, and/or any action taken in reliance on the contents of this 
> e-mail is strictly prohibited and may be unlawful. Where permitted by 
> applicable law, this e-mail and other e-mail communications sent to and from 
> Cognizant e-mail addresses may be monitored.
> _______________________________________________
> 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