PREFIX co: <http://abc.com/ns/concepts#>
PREFIX d: <http://abc.com/ns/data#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
SELECT ?p1
(GROUP_CONCAT(?y; SEPARATOR=',') AS ?ys)
?z
?c1
?e1
WHERE {
VALUES ?p1 { d:001 d:002 d:003 d:004 d:005 d:006 d:007 d:008 d:009 d:010 d:011 d:012 d:013 d:014 d:015 d:016 d:017 d:018 d:019 d:020 }
?p1 co:f1 ?y ;
co:g1 ?m1 ;
co:h1 ?n1 ;
co:i1 ?b1 ;
OPTIONAL { ?p1 co:j1 ?d1 . ?d1 skos:prefLabel ?e1 .}
OPTIONAL { ?p1 co:k1 a1 . a1 co:l1 ?z . }
?b1 skos:prefLabel ?c1 .
}
GROUP BY ?p1 ?c1 ?e1 ?z
ORDER BY ASC(?m1) DESC(?n1)
prefix co: <http://abc.com/ns/concepts#>
prefix d: <http://abc.com/ns/data#>
prefix skos: <http://www.w3.org/2004/02/skos/core#>
Projection(?p1, ?ys, ?z, ?c1, ?e1) [cardinality=0]
OrderBy(ASC(?m1), DESC(?n1)) [cardinality=0]
Group(by=[?p1, ?e1, ?z, ?c1] aggregates=[(GROUP_CONCAT(?y, ",") AS ?ys)]) [cardinality=0]
HashJoin[?b1] [cardinality=0]
MergeJoinOuter[?p1] [cardinality=0]
MergeJoinOuter[?p1] [cardinality=0]
MergeJoin[?p1] [cardinality=0]
Sort(?p1) [cardinality=20]
VALUES (?p1) {
(http://abc.com/ns/data#015 )
(http://abc.com/ns/data#008 )
(http://abc.com/ns/data#004 )
(http://abc.com/ns/data#018 )
(http://abc.com/ns/data#020 )
(http://abc.com/ns/data#006 )
(http://abc.com/ns/data#019 )
(http://abc.com/ns/data#005 )
(http://abc.com/ns/data#009 )
(http://abc.com/ns/data#014 )
(http://abc.com/ns/data#010 )
(http://abc.com/ns/data#007 )
(http://abc.com/ns/data#017 )
(http://abc.com/ns/data#013 )
(http://abc.com/ns/data#001 )
(http://abc.com/ns/data#002 )
(http://abc.com/ns/data#003 )
(http://abc.com/ns/data#011 )
(http://abc.com/ns/data#016 )
(http://abc.com/ns/data#012 )
}
MergeJoin[?p1] [cardinality=731K]
Scan[PSOC](?p1, co:f1, ?y) [cardinality=806K]
MergeJoin[?p1] [cardinality=445K]
Scan[PSOC](?p1, co:h1, ?n1) [cardinality=494K]
MergeJoin[?p1] [cardinality=445K]
Scan[PSOC](?p1, co:i1, ?b1) [cardinality=447K]
Scan[PSOC](?p1, co:g1, ?m1) [cardinality=494K]
Sort(?p1) [cardinality=108K]
MergeJoin[?d1] [cardinality=108K]
Scan[POSC](?p1, co:j1, ?d1) [cardinality=108K]
Scan[PSOC](?d1, skos:prefLabel, ?e1) [cardinality=64K]
Sort(?p1) [cardinality=316K]
MergeJoin[a1] [cardinality=316K]
Scan[POSC](?p1, co:k1, a1) [cardinality=316K]
Scan[PSOC](a1, co:l1, ?z) [cardinality=316K]
Scan[PSOC](?b1, skos:prefLabel, ?c1) [cardinality=64K]
--
-- --
You received this message because you are subscribed to the C&P "Stardog" group.
To post to this group, send email to sta...@clarkparsia.com
To unsubscribe from this group, send email to
stardog+u...@clarkparsia.com
For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
Ajay,How did you get 800ms, e.g. how many times did you run the query and did the average include the first run or not?Also, I don't think the optimizer can do a better job with VALUES here. I suspect that the only issue here is the OPTIONALs. Can you run two additional queries to report how many results the following two BGPs return:select (count(*) as ?c) where { ?p1 co:j1 ?d1 . ?d1 skos:prefLabel ?e1 . }andselect (count(*) as ?c) where { ?p1 co:j1 ?d1 . ?d1 skos:prefLabel ?e1 . }
What is a good strategy to handle optional values. What would you suggest?Is it recommended to keep some default value like null/nil maybe (so that nothing is optional in data)?
Thank you Pavel.I put VALUES inside both OPTIONALs and the issue is solved. Now I get results within 200 ms.
Also, I found Sparql Algebra (which I was not aware of) good tool for learning. Are there any documents (general/stardog specific) that explain this. I found some but are difficult read (for example W3C specification).
--