I was looking at a couple of queries and found that

SELECT * WHERE {
 ?x a <foo> .
 OPTIONAL{ ?x <bar> ?bar } .
 OPTIONAL{ ?y <baz> ?baz }
}

becomes
(leftjoin
  (leftjoin
    (bgp (triple ?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<file:///home/claude/workspace/RoadMap/foo>))
    (bgp (triple ?x <file:///home/claude/workspace/RoadMap/bar> ?bar)))
  (bgp (triple ?x <file:///home/claude/workspace/RoadMap/baz> ?baz)))

BUT ....

SELECT * WHERE {
 ?x a <foo> .
 OPTIONAL{ ?x <bar> ?bar .
    ?y <baz> ?baz }
}

becomes

leftjoin
  (bgp (triple ?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<file:///home/claude/workspace/RoadMap/foo>))
  (bgp
    (triple ?x <file:///home/claude/workspace/RoadMap/bar> ?bar)
    (triple ?x <file:///home/claude/workspace/RoadMap/baz> ?baz)
  ))


It seems to me that the 2nd form is much more efficient.  (Am I wrong here?)
That leads me to ask "Is there ever a time when 2 adjacent option
statements can not be merged into a single statement?"
And if not, should the parser be optimized to do the merging?

Claude

-- 
I like: Like Like - The likeliest place on the web<http://like-like.xenei.com>
Identity: https://www.identify.nu/[email protected]
LinkedIn: http://www.linkedin.com/in/claudewarren

Reply via email to