[xquery-talk] General comparisons of speed of xquery vs. xslt
mhk at mhk.me.uk
Wed Apr 28 10:23:30 PDT 2004
> Are you sure, that XSLT generally is faster than XQuery?
Of course not. I said nothing of the kind! Let me repeat what I said:
(a) when running against a persistent database with pre-built indexes,
XQuery is definitely easier to optimize than XSLT
(b) with in-memory transformations there is no intrinsic reason why XQuery
should be faster than XSLT
(c) XSLT has some features, notably xsl:key, that enable improved
performance, and which are not present in XQuery [clearly such a feature
makes no difference unless you use it: but for tasks involving grouping, for
example, keys make an enormous difference]
> We did an independent benchmark.
> 1. Oracle XQuery implementation
> 2. Saxon XQuery implementation
> 3. Xalan XSLTC implementation
> 4. Saxon XSL implementation
> In the case of both XQuery implementations we are seeing
> results (100's
> of milliseconds) better than using XSLT? Although this is not,
> necessarily, an apples to apples comparison; the numbers have
> led us to
> believe that the XQuery implementations are faster.
I would be very interested to see details of your benchmarks. In terms of
the Saxon implementation, I can think of some things that probably perform
better under XQuery and some that probably perform better under XSLT.
(Generally, the compile-time rewrite optimizations are more thorough under
XQuery, but the tree construction is better pipelined under XSLT). I haven't
made any comprehensive measurements. And of course it's always difficult
when comparing the same code written in two languages because one can always
argue that it's not written optimally in one case or the other (I've always
claimed that results in a benchmark tell you as much about the skills and
knowledge of the benchmarkers as about the products they are testing...).
What would be really valuable, of course, is a translation into XQuery of a
benchmark such as XSLTMark  but that would be a fair bit of work. (And
the controversies over the way this was run should also act as a warning of
the difficulties of making unbiased comparisons!)
More information about the talk