query-6944f49bca6995c245ec98a12a8f29f5
Why is this querry so slow, can it be made faster?Hi all, I am trying to make a query that would return every entity associated in any way with Donald trump This is my query:
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 rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?p ?pLabel ?entity ?entityLabel ?prop ?property1Label WHERE
{
?property1 rdf:type wikibase:Property. #get all possible propreties
?property1 wikibase:directClaim ?prop .
filter(?prop not in(wdt:P1889,wdt:P1889))#filter out unwanted propreties (e.g. "different from")
{?entity ?prop wd:Q22686 . }#select all entities that have Q as proprety
Union
{wd:Q22686 ?prop ?entity .}#and select all propreties of Q
?entity wdt:P31 ?p.#check the category of ?entity
?p wdt:P279* ?p2.#and all of it's "subclasses"
filter(?p2 in(wd:Q164509,wd:Q164509)) #and keep it only if it is a subclass of one of the following
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}group by ?p ?pLabel ?entity ?entityLabel ?prop ?property1Label
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v4("?entity"):::projected
v5("?p"):::projected
v1("?p2")
v2("?prop"):::projected
v3("?property1")
c10(["bd:serviceParam"]):::iri
c4(["wikibase:Property"]):::iri
c12(["#91;AUTO_LANGUAGE#93;,en"]):::literal
c6(["wd:Q22686"]):::iri
list0c1(["wd:Q164509"]):::iri
list0c1 --o f0
list0c1 --o f0
f0[[" in "]]
f0 --> v1
f1[["?prop != 'wdt:P1889'?prop != 'wdt:P1889'"]]
f1 --> v2
v3 --"a"--> c4
v3 --"wikibase:directClaim"--> v2
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
c6 -->v2--> v4
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v4 -->v2--> c6
end
union0r <== or ==> union0l
end
v4 --"wdt:P31"--> v5
v5 --"wdt:P279"--> v1
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c10 --"wikibase:language"--> c12
end