[
https://issues.apache.org/jira/browse/JENA-638?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13902006#comment-13902006
]
Andy Seaborne commented on JENA-638:
------------------------------------
While swapping {{OrderByDistinctApplication}} and {{TopN}} helps in this
example, it does not cover all cases. The testing would be better all done in
{{TopN}} and not rely on a previous transformation of
{{OrderByDistinctApplication}} making {{TopN}} self-contained.
{{OrderByDistinctApplication}} is still useful - {{TopN}} only works when there
is a {{LIMIT}}.
> Optimization OrderByDistinctApplication can enable better TopN optimization.
> ----------------------------------------------------------------------------
>
> Key: JENA-638
> URL: https://issues.apache.org/jira/browse/JENA-638
> Project: Apache Jena
> Issue Type: Improvement
> Components: ARQ, Optimizer
> Affects Versions: Jena 2.11.1
> Reporter: Andy Seaborne
> Assignee: Andy Seaborne
>
> There is a new opportunity for transformation of slice/order to a TopN
> execution.
> Currently, {{OrderByDistinctApplication}} is done after TopN.
> If {{OrderByDistinctApplication}} is done before TopN optimization, then the
> algebra may have the form slice/order/distinct/project which is can be
> executed as a TopN query. This form does not appear in algebra expressions
> directly from queries; the modifier order is slice/distinct/project/order
> which, in general, is not safe for TopN execution.
> However, {{OrderByDistinctApplication}} picks out a condition for it's own
> optimization, that leaves the resultant algebra as further transformable to
> TopN.
> Currently:
> {noformat}
> SELECT DISTINCT ?z
> WHERE
> { ?s ?p ?z }
> ORDER BY ?z
> LIMIT 5
> {noformat}
> Compiled to algebra:
> {noformat}
> (slice _ 5
> (distinct
> (project (?z)
> (order (?z)
> (bgp (triple ?s ?p ?z))))))
> {noformat}
> After optimization: TopN did not apply:
> {noformat}
> (slice _ 5
> (order (?z)
> (distinct
> (project (?z)
> (bgp (triple ?s ?p ?z))))))
> {noformat}
> but this is possible:
> {noformat}
> (top (5 ?z)
> (distinct
> (project (?z)
> (bgp (triple ?s ?p ?z)))))
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)