- From: Michael Kay <mhk@mhk.me.uk>
- Date: Sun, 27 Jun 2004 22:54:44 +0100
- To: "'Houman Khorasani'" <khorasani@web.de>, <mrys@microsoft.com>, <www-ql@w3.org>
Yes, at present Saxon will not detect that the expression for $i in ($temptltt) where ($i/min = $distinctMin) is used three times and will therefore compute it repeatedly. Michael Kay > -----Original Message----- > From: Houman Khorasani [mailto:khorasani@web.de] > Sent: 27 June 2004 10:41 > To: mrys@microsoft.com; 'Michael Kay'; www-ql@w3.org > Subject: RE: Question about Let clause > Importance: High > > Hello Michael Kay, > Hello Michael Rys, > > Thank you for the information. Actually I didn't first > consider that every > query processor handles the problem in a different way. But > since I use > Saxon 8.0 I still was curious to see how Saxon handles the > situation. The > -e option was very helpful and I analyzed the data for a long time. > > I would say the first 'let' seems to be proceeding just once, > not because it > contains a node construction, but because the nested FLWOR > has no dependency > on the outer world. > > If I would do something stupid like this, then the let clause will be > computed every time since it has a dependency on the 'for' iteration. > > > For $STUPID in doc("list.xml")//something > > let $temptltt := for $wbtt in > doc("wisc_berkeley_tracetime.xml")//row > for $wb in doc("wisc_berkeley_3days.xml")//row > where ( ($wbtt/dat = '20000801000000') > and ($wb/dat > = '20000801000000') and ($wbtt/min = (round($wb/tick div 600000))) ) > return <g> { $wbtt/min } > { $wb/dlay } > { $wbtt/dat } > { $wbtt/rID } > { $STUPID } > </g> > > > But now considering the real query; regarding the explanation > of Saxon's > evaluation ( -e ) I would say the first 'let' proceeds just > once without any > dependency to other iterations and stays 'outer loop'. > > But the last three 'let' clauses change their value every > time the 'for' > expression (before them) iterates. So these three 'let' clauses are > dependent of the value $distinctMin and have to stay in the loop. > > > What do you think? > > Best Regards > Houman > > let $temptltt := for $wbtt in > doc("wisc_berkeley_tracetime.xml")//row > for $wb in doc("wisc_berkeley_3days.xml")//row > where ( ($wbtt/dat = '20000801000000') > and ($wb/dat > = '20000801000000') and ($wbtt/min = (round($wb/tick div 600000))) ) > return <g> { $wbtt/min } > { $wb/dlay } > { $wbtt/dat } > { $wbtt/rID } </g> > > for $distinctMin in distinct-values($temptltt//min) > > let $totalDelay_distinctMin := for $i in ($temptltt) > where ($i/min = $distinctMin) > return $i/dlay > > let $rID := for $i in $temptltt > where ($i/min = $distinctMin) > return $i/rID > > let $dat := for $i in $temptltt > where ($i/min = $distinctMin) > return $i/dat > > return > <ROW> > { $rID[1] } > <min>{ $distinctMin }</min> > { $dat[1] } > <avgDelay> { round-half-to-even( > (avg($totalDelay_distinctMin)),4 ) } </avgDelay> > </ROW> > > > > >
Received on Sunday, 27 June 2004 17:55:18 UTC