Sorry, I am looking at this again. Are you saying that in

(prefix ((p1: <file:///C:/Temp/t1>)
         (p2: <file:///C:/Temp/t2>))
  (distinct
    (project (?R1 ?optionalValue)
      (conditional
        (assign ((?R1 <https://perfrrs.ibm.com:9443/rm/resources/_r1>))
          (bgp (triple <https://perfrrs.ibm.com:9443/rm/resources/_r1> 
p1:pr1 <https://perfjts.ibm.com:9443/jts/process/project-areas/p>)))
        (bgp (triple ?R1 p2:pr2 ?optionalValue))))))

?R1 is not always bound to <https://perfrrs.ibm.com:9443/rm/resources/_r1
>? And therefore, are you saying that ?R1 can be any value which satisfies 
p2:pr2 ?optionalValue ?

I still don't understand why the assign optimization cannot be pushed into 
the optional in the query 

PREFIX p1:<t1>
PREFIX p2:<t2>
SELECT DISTINCT ?R1 ?optionalValue
WHERE
{ 
?R1 p1:pr1 <https://perfjts.ibm.com:9443/jts/process/project-areas/p>
OPTIONAL
{ ?R1 p2:pr2 ?optionalValue  }
FILTER ( ?R1 = <https://perfrrs.ibm.com:9443/rm/resources/_r1>) 
}

is there perhaps a different way to express this? 

Simon



From:
Andy Seaborne <[email protected]>
To:
Simon Helsen/Toronto/IBM@IBMCA
Cc:
[email protected]
Date:
07/18/2012 05:42 PM
Subject:
Re: optimization opportunity lost in 2.7.x  which existed in 2.6.x?



On 18/07/12 16:25, Simon Helsen wrote:
> Andy,
>
> I have simplified the scenario a little bit. So the following query
>
> PREFIX p1:<t1>
> PREFIX p2:<t2>
> SELECT DISTINCT ?R1 ?optionalValue
> WHERE
> {
> ?R1 p1:pr1 <https://host:9443/jts/process/project-areas/p>
> FILTER ( ?R1 = <https://host:9443/rm/resources/_r1>)
> OPTIONAL
> { ?R1 p2:pr2 ?optionalValue }
> }
>
> leads to
>
> (prefix ((p1: <file:///C:/Temp/t1>)
>           (p2: <file:///C:/Temp/t2>))
>    (distinct
>      (project (?R1 ?optionalValue)
>        (filter (= ?R1 <https://host:9443/rm/resources/_r1>)
>          (conditional
>            (bgp (triple ?R1 p1:pr1
> <https://host:9443/jts/process/project-areas/p>))
>            (bgp (triple ?R1 p2:pr2 ?optionalValue)))))))
>
> whereas the following query
>
> PREFIX p1:<t1>
> PREFIX p2:<t2>
> SELECT DISTINCT ?R1 ?optionalValue
> WHERE
> {
> {
> ?R1 p1:pr1 <https://host:9443/jts/process/project-areas/p>
> FILTER ( ?R1 = <https://host:9443/rm/resources/_r1>)
> }
> OPTIONAL
> { ?R1 p2:pr2 ?optionalValue }
> }
>
> leads to
>
> (prefix ((p1: <file:///C:/Temp/t1>)
>           (p2: <file:///C:/Temp/t2>))
>    (distinct
>      (project (?R1 ?optionalValue)
>        (conditional
>          (assign ((?R1 <https://host:9443/rm/resources/_r1>))
>            (bgp (triple <https:/host:9443/rm/resources/_r1> p1:pr1
> <https://perfjts.ibm.com:9443/jts/process/project-areas/p>)))
>          (bgp (triple ?R1 p2:pr2 ?optionalValue))))))
>
> So, looking at this in more detail, the former plan surprises me a bit
> because it proposes to evaluate p1:pr1 as optional, even though I didn't
> express that in the query.

Yes, you did.

"conditional" is a binary operator, an optimized for of leftjoin.  The 
first arg is the fixed side and the second args the conditional part.


{ ?s ?p ?o OPTIONAL { ?s1 ?p1 ?o1 } }

becomes

(leftjoin
    (bgp (triple ?s ?p ?o)
    (bgp (triple ?s1 ?p1 ?o1))

which is executed as

(conditional
    (bgp (triple ?s ?p ?o)
    (bgp (triple ?s1 ?p1 ?o1))

(sequence) is rather different.

> WHERE
> {
> {
> ?R1 p1:pr1 <https://host:9443/jts/process/project-areas/p>
> FILTER ( ?R1 = <https://host:9443/rm/resources/_r1>)
> }
> OPTIONAL
> { ?R1 p2:pr2 ?optionalValue }
> }

is a different query because FILTERS are group-wide, a group being what 
is between {} (caveat a special case in OPTIONAL not occuring here).

Adding the extra {} means the FILTER is applied to

  ?R1 p1:pr1 <https://host:9443/jts/process/project-areas/p>

alone.

                 Andy



Reply via email to