Warning:
This wiki has been archived and is now read-only.

CommentResponse:DB-13

From SPARQL Working Group
Jump to: navigation, search

David,

The order of modifiers is:

  • Order by
  • Projection
  • Distinct/Reduced
  • Offset/Limit

Projection can come between distinct and order. DISTINCT will apply after projection to the narrower range of variables, but the ORDER BY may sort based on a variable projected away. Doing the DISTINCT before ORDER BY would be an observable change.

SELECT DISTINCT ?s
WHERE
  { ?s ?p ?x }
ORDER BY ?x

==>

  (distinct
    (project (?s)
      (order (?x)
        (bgp (triple ?s ?p ?x)))))

As you note, optimizers are free to spot times when the transformation is possible and an advantage.

We would be grateful if you would acknowledge that your comment has been answered by sending a reply to this mailing list.

Andy (on behalf of the SPARQL WG)