Changes

Jump to navigation Jump to search
232 bytes added ,  18:52, 18 November 2020
* {{Code|where}} clauses are rewritten to predicates.
* {{Code|if}} expressions in the return clause are rewritten to {{Code|where}} clauses.
 Since {{Version|9.4}}, the * The last {{Code|for}} clause is merged into the {{Code|return}} clause and rewritten to a [[XQuery_3.0|Simple_Map_Operator|simple map]] expression.
Various of these rewriting are demonstrated in the following example:
| Distributivity
|- valign="top"
| <code>$a and or not($a)</code>
| <code>true()</code>
| Tertium non datur
for $p in $auction/site/people/person
let $a :=
for $t in $auction/site/closedauctionsclosed_auctions/closedauctionclosed_auction
where $t/buyer/@person = $p/@id
return $t
}</item>
</syntaxhighlight>
 
If the accessed database is not known at compile time, or if you want to give a predicate preference to another one, you can [[Indexes#Enforce Rewritings|enforce index rewritings]].
=Evaluation-Time Optimizations=
==Comparisons==
In many cases, the amount of data to be processed is only known after the query has been compiled. Moreover, the data that is looped through expressions may change. In those cases, the best optimizations needs to be chosen at runtime.
If sequences of items are compared against each other, a dynamic hash index will be generated, and the total number of comparisons can be significantly reduced. In the following example, <code>count($input1) * count($input2)</code> comparisons would need to be made without the intermediate index structure:
Bureaucrats, editor, reviewer, Administrators
13,551

edits

Navigation menu