Bug #4201
closedMissed optimization opportunity: conditional sorting
100%
Description
Certain functions and operators such as exists(), sum(), "=", do not require the operand(s) to be in any particular order; the optimizer therefore attempts to remove any unnecessary sorting into document order for such operands.
If the operand is a ConditionalSorter
, which is designed to sort expressions such as $var/items only when $var is not a singleton, then the ConditionalSorter is not eliminated by this step.
(Found during investigation of performance bug #4198)
Updated by Michael Kay almost 5 years ago
- Fixed in Maintenance Release 9.9.1.1 added
The method ExpressionTool.avoidDocumentSort()
does in fact eliminate an unnecessary ConditionalSorter
from the expression tree. However, this method only handles cases where the sort is unnecessary because the expression is already sorted; it doesn't handle the case where the sort is unnecessary because of the semantics of the expression that uses the operand (e.g. sum()
).
fn:sum(), and other similar functions, are marked with the property UO (for unordered) in the function catalog and this results in SystemFunctionCall.optimize()
calling Expression.unordered()
on the operand. This method is not implemented by the ConditionalSorter
class.
Updated by Michael Kay almost 5 years ago
- Status changed from New to Resolved
- Priority changed from Low to Normal
- Applies to branch 9.9, trunk added
- Fix Committed on Branch 9.9, trunk added
ConditionalSorter
now implements the unordered()
method.
Updated by O'Neil Delpratt almost 5 years ago
- Status changed from Resolved to Closed
- % Done changed from 0 to 100
- Fixed in Maintenance Release 9.9.1.4 added
- Fixed in Maintenance Release deleted (
9.9.1.1)
Bug fix applied in the Saxon 9.9.1.4 maintenance release
Please register to edit this issue