[xquery-talk] XQuery coding style: nested FLWOR expressions

Philippe Michiels philippe.michiels at gmail.com
Wed Apr 12 11:57:45 PDT 2006

I think that if a language allows users to specify queries in different
ways, users will tend to do so. Many people indeed do know SQL and will
tend to shape their queries accordingly. I used to do it myself when
learning XQuery and I see many students doing it when teaching XQuery. 

You should also consider the fact that not all queries come from users.
Some queries will be generated and in it is likely that in those cases,
many of the queries will be overly verbose. In that sense, I think this
particular XMark query may be a good test for XQuery optimizers.


On Wed, 2006-04-12 at 09:16 +0100, Michael Kay wrote:
> I've been looking again recently at some of the XMark benchmark queries.
> I'm wondering what it is about the language that makes people write things
> like this (Q9):
> for $p in /site/people/person
> let $a := for $t in /site/closed_auctions/closed_auction
>           let $n := for $t2 in /site/regions/europe/item
>                        where  $t/itemref/@item = $t2/@id
>                        return $t2
>              where $p/@id = $t/buyer/@person
>              return <item> {$n/name} </item>
> return <person name="{$p/name}">{ $a }</person>
> when they could have written
> for $p in /site/people/person
> return <person name="{$p/name}"> { 
>   for $t in /site/closed_auctions/closed_auction[buyer/@person = $p/@id]
>   return <item> {/site/regions/europe/item[@id = $t/itemref/@item]/name}
> </item> 
> } </person>
> Is it just a torture test for optimizers? Did the author think this was the
> best/easiest way to write the query? Does anyone else think it is? Is it the
> way SQL users' brains are wired?
> Michael Kay
> http://www.saxonica.com/ 
> _______________________________________________
> talk at xquery.com
> http://xquery.com/mailman/listinfo/talk
Philippe Michiels (PhD Student)
Advanced Database Research and Modeling
University of Antwerp
t: +32 3 265 38 80
w: http://www.adrem.ua.ac.be/~michiels

More information about the talk mailing list