Hi @pavel
Thank you for your reply. We've implemented the suggested approach to modify our queries, but we're now encountering kind of BINDing problem for majority of our queries. For instance, we had query like this
SELECT DISTINCT ?Acc ?Held_By ?Organisation ?Cap
WHERE {
BIND(?this AS ?that)
?Cap (rdfs:subClassOf)* ?that
OPTIONAL
{ ?Cap C:deleToOrg ?Organisation
OPTIONAL
{ ?Pos V:manages ?Organisation .
?Pos V:occupyingRole ?Acc .
?Pos V:heldBy ?Held_By
}
}
}
we modified it to:
SELECT DISTINCT ?graph ?Acc ?Held_By ?Organisation ?Cap
WHERE { GRAPH ?graph {
BIND(?this AS ?that)
?Cap (rdfs:subClassOf)* ?that
OPTIONAL
{ ?Cap C:deleToOrg ?Organisation
OPTIONAL
{ ?Pos V:manages ?Organisation .
?Pos V:occupyingRole ?Acc .
?Pos V:heldBy ?Held_By
}
}
}
}
When we use Stardog studio and a manual BIND like BIND(<example.com/input1> AS ?this)
to it and run it, it works properly and return the expected number of results. But when we use SNARL to bind (by using query.parameter) it and execute it through our JAVA code, it is executed but BINDing is not applied. Even query explain shows that the BIND is applied but seems that it does not affect
# reused
From named <XXXX1>
From named <XXXX2>
From named <XXXX3>
From named <XXXX4>
Distinct [#271K]
`─ Projection(?graph, ?Acc, ?Held_By, ?Organisation, ?Cap) [#271K]
`─ MergeJoinOuter(?Capability) [#271K]
+─ Bind(<example.com/input1> AS ?this) sortedBy=?Cap [#271K]
│ `─ PropertyPath(?Cap -> ?that in ?graph, minLength=0, sortedBy=?Cap) [#271K]
│ `─ Scan[PSOC](?Cap, rdfs:subClassOf, ?that){?graph} [#11K]
`─ HashJoinOuter(?Organisation) [#133]
+─ Scan[PSOC](?Cap, <http://x.com/core/C#deleToOrg>, ?Organisation){?graph} [#133]
`─ NaryJoin(?Pos) [#23]
+─ Scan[PSOC](?Pos, <http://x.com/core/V#heldBy>, ?Held_By){?graph} [#55]
+─ Scan[PSOC](?Pos, <http://x.com/core/V#manages>, ?Organisation){?graph} [#29]
`─ Scan[PSOC](?Pos, <http://x.com/core/V#occupyingRole>, ?Acc){?graph} [#63]
On the other hand, Stardog studio Plan (and Profiler) is as follows
From named <XXXX1>
From named <XXXX2>
From named <XXXX3>
From named <XXXX4>
Slice(offset=0, limit=1000) [#2], results: 11, wall time: 0 ms (0.0%)
`─ Distinct [#2], memory: {total=256K (30.8%); max=224K}, results: 11, wall time: 2 ms (4.7%)
`─ Projection(?graph, ?Acc, ?Held_By, ?Organisation, ?Cap) [#2], results: 11, wall time: 0 ms (0.0%)
`─ MergeJoinOuter(?Cap) [#2], results: 11, wall time: 2 ms (4.7%)
+─ Sort(?Cap) [#2], memory: {total=256K (30.8%)}, results: 11, wall time: 2 ms (4.7%)
│ `─ MergeJoin(?that) [#2], results: 11, wall time: 1 ms (2.3%)
│ +─ Bind(example.com/input1 AS ?this) (example.com/input1 ?that) sortedBy=?that [#1], results: 1, wall time: 0 ms (0.0%)
│ `─ PropertyPath(?Cap -> ?that in ?graph, minLength=0, sortedBy=?that, reversed) [#11], results: 11 (with gaps), wall time: 6 ms (14.0%)
│ +─ Bind(example.com/input1 AS ?that) sortedBy=?that [#1], results: 1 (with gaps), wall time: 0 ms (0.0%)
│ `─ Scan[POSC](?Cap, http://www.w3.org/2000/01/rdf-schema#subClassOf, ?that){?graph} [#11K]
`─ HashJoinOuter(?Organisation) [#133], memory: {total=320K (38.5%); max=288K}, results: 7 (with gaps), wall time: 1 ms (2.3%)
+─ Scan[PSOC](?Cap,http://x.com/core/C#deleToOrg, ?Organisation){?graph} [#133], results: 8 (with gaps), wall time: 1 ms (2.3%)
`─ NaryJoin(?Pos) [#23], results: 21, wall time: 7 ms (16.3%)
+─ Scan[PSOC](?Pos, http://x.com/core/V#heldBy, ?Held_By){?graph} [#55], results: 36 (with gaps), wall time: 1 ms (2.3%)
+─ Scan[PSOC](?Pos, http://x.com/core/V#manages, ?Organisation){?graph} [#29], results: 31 (with gaps), wall time: 0 ms (0.0%)
`─ Scan[PSOC](?Pos, http://x.com/core/V#occupyingRole, ?Acc){?graph} [#63], results: 39 (with gaps), wall time: 1 ms (2.3%)
Plans are different, I'm not sure what's going on here. Maybe we're not using SNARL properly or something else. It would be appreciated if you can share your thoughts with us on this. It may worth nothing that before using named graphs, the same with the same binding approach from java worked fine. Thank you