query-69a068178a6757e089751ca0e777c87a

rq turtle/ttl

Path query running very very slowWhy is the following query so slow? relationships. First it finds all the items in the tree, then it sees which ones can't be linked by P279s. (P279)subclass of tree, and then see which have hierarchical relationships in that tree that can't currently be 'explained' by (P1014)Art & Architecture Thesaurus ID The query is intended to extract all the currently matched items in the costume sector of the to be a piece of cake -- 600 or so items, arranged in a direct hierarchical tree. Blazegraph ought to be able to do this in a fraction of a second. But currently just this initial subquery is taking at least 50 seconds, and the query as a whole is timing out. oughtI think the second half of the query is reasonably efficient. The problem is the initial subquery, which that's being iterated over, Blazegraph seems to be making really heavy weather of it. (p:P1014/pq:P361) I think there would be no problem. But because it's a compound relation Pnnn*If the first part were a simple path relation, Can anyone suggest a way to optimise this?

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel ?class ?classLabel ?higher ?higherLabel 
WHERE {
    {
   SELECT ?item WHERE {
       ?item (p:P1014/pq:P361)* wd:Q9053464 .

   } 
}. 
   ?item p:P1014/pq:P361 ?higher .

   OPTIONAL {
       ?item wdt:P279+ ?higher .

       BIND(1 AS ?subclassed) .   
   }
   FILTER (!bound(?subclassed)) .

   OPTIONAL {
       ?item wdt:P279 ?class .
   }
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY ?higherLabel ?itemLabel

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v6("?class"):::projected v5("?higher"):::projected v1("?higherLabel"):::projected v4("?item"):::projected v2("?itemLabel"):::projected v6("?subclassed") a1((" ")) a2((" ")) c6(["bd:serviceParam"]):::iri c3(["wd:Q9053464"]):::iri c8(["#91;AUTO_LANGUAGE#93;,en"]):::literal f0[["not bound(?subclassed)"]] f0 --> v6 v4 --"p:P1014"--> a1 a1 --"p:qualifier/P361"--> c3 v4 --"p:P1014"--> a2 a2 --"p:qualifier/P361"--> v5 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v4 -."p:direct/P279".-> v5 bind1[/"'1^^xsd:integer'"/] bind1 --as--o v6 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v4 -."p:direct/P279".-> v6 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c6 --"wikibase:language"--> c8 end