Project

Profile

Help

Bug #4201

closed

Missed optimization opportunity: conditional sorting

Added by Michael Kay almost 5 years ago. Updated almost 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Performance
Sprint/Milestone:
-
Start date:
2019-04-19
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
9.9, trunk
Fix Committed on Branch:
9.9, trunk
Fixed in Maintenance Release:
Platforms:

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)

Actions #1

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.

Actions #2

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.

Actions #3

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

Also available in: Atom PDF