RE: Question about Let clause

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 05:42:04 UTC