On 03/06/16 18:28, Zen 98052 wrote:
Hi,
Is there a way to rewrite this Sparql query to run more efficiently?
SELECT ?s
WHERE
{
?s <http://foo/bar> ?o1, ?o2 .
?o2 <http://foo/id> "some id" .
FILTER (?o1 != ?o2) .
}
It seems to me this can be optimized, I am still trying to figure it out.
Yes - by the filter placement transform TransformFilterPlacement
There is no need to wait for ?o2 <http://foo/id> "some id" .
The filter can be executed after ?s <http://foo/bar> ?o1, ?o2 . as both
?o1 and ?o2 are bound.
BGPs are left alone if
context.isTrueOrUndef(ARQ.optFilterPlacementBGP) ;
See Optimize.rewrite
TDB turns it off by setting that context values on each dataset:
dsg.getContext().set(ARQ.optFilterPlacementBGP, false) ;
(then does it itself in "NodeId" space, not in "Node")
You can experiment using the command line tools:
arq.qparse --print=opt --query=YourQuery.rq
Andy
Thanks,
Z