query-69a068178a6757e089751ca0e777c87a
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
- https://query.wikidata.org/sparql
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