[xquery-talk] FLOWR vs Xpath axis syntax - Performance

Liam R E Quin liam at w3.org
Tue Jul 31 10:42:20 PDT 2012


On Tue, 2012-07-31 at 17:25 +0100, Ihe Onwuka wrote:
> I vaguely remember reading somewhere that a preference for what I
> would call axis notation has performance advantages over the
> equivalent FLOWR code.
> 
> I certainly recall reading that  XPath predicates perform better than
> where clauses in FLOWR.

It depends (as David Lee) said on the implementation, but I think today
you're unlikely to find a difference in any modern XQuery
implementation, except in a few cases to do with effective boolean
values, where the "where" syntax might be faster:
    //a[$x]
vs.
    for $item in //a where $x return $item
or
    for $item at $n in //a where $n eq $x return $item


In the past I've seen a factor of two difference between one form or the
other for moderately small data sets (under a megabyte of XML, say), but
that was quite some time ago, and the implementations weren't consistent
in which was faster.

If performance with XQuery is an issue, consider...
(1) use an XML-native database in order to avoid re-parsing the XML each
time;
(2) do actual measurements

Liam


-- 
Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/
Pictures from old books: http://fromoldbooks.org/
Ankh: irc.sorcery.net irc.gnome.org freenode/#xml



More information about the talk mailing list