[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

unordered {} and fn:unordered()

Michael Kay mhk at mhk.me.uk
Thu Jan 19 11:10:24 PST 2006


sql order by unordered
> 
> I am wondering whether you have noticed that your favorite XQuery 
> processor indeed realizes such an advantage when it processes 
> expressions of the form unordered {e} or fn:unordered(e)?

I think the facility was added primarily for people who are mapping XQuery
to SQL, because generating/executing a SQL expression that produces results
in the right order can be a lot of work. Native XML storage tends to have
intrinsic support for ordering, so it's less of an issue. There may be
optimisations one can do in unordered mode, but as far as I'm concerned
they're not very high up my list - apart from anything else, it's much more
important to optimize badly written queries than to optimize well-written
ones (and I don't regard setting the default to "unordered" as viable in a
world where people think of their data in XML terms rather than in
relational terms).

When Saxon finds that it needs to do a sort, it's either because the user
asked for it, or because it's delivering results "in document order with
duplicates eliminated". Since "unordered" doesn't remove the obligation to
remove duplicates, and since the simplest way of removing duplicates is to
sort, "unordered" doesn't actually help much in this scenario. There are a
very few exceptions, for example unordered(preceding-sibling::x) will return
the siblings in reverse document order. (The danger, of course, is that
people will rely on that!)

Michael Kay
http://www.saxonica.com/




PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.