query-9271de3b27a04c091da5a5212c19a3b2

rq turtle/ttl

Query time outHello ! Could you perhaps help me on why this once-worked-well query times out now ?

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX p: <http://www.wikidata.org/prop/>
#defaultView:Map
SELECT ?item ?country ?coord {
 VALUES ?country { wd:Q1050 } .                             #select a country here, works also with any administrative territory having the 4 east, west, south and north bounds
   ?country p:P1332 [ ps:P1332 ?north; psv:P1332 ?nValue ];
          p:P1333 [ ps:P1333 ?south; psv:P1333 ?sValue ];
          p:P1334 [ ps:P1334 ?east;  psv:P1334 ?eValue ];
          p:P1335 [ ps:P1335 ?west;  psv:P1335 ?wValue ].
 ?nValue wikibase:geoLatitude  ?nLat . 
 ?sValue wikibase:geoLatitude  ?sLat . 
 ?eValue wikibase:geoLongitude ?eLon . 
 ?wValue wikibase:geoLongitude ?wLon . 
 ?item p:P625 [ a wikibase:BestRank; ps:P625 ?coord; psv:P625 ?cValue ] .
 ?cValue wikibase:geoLatitude  ?lat  . 
 ?cValue wikibase:geoLongitude ?lon  . 
 ?cValue  wikibase:geoGlobe ?globe . 
BIND(COALESCE(?globe,wd:Q2) as ?Globe)
FILTER (?Globe =wd:Q2)                                    #select only Earth-like coordinates
MINUS { ?item wdt:P17 [] } .                              #has the item any P17 value ? should be the 
MINUS { ?item (wdt:P31/wdt:P279*) wd:Q4830453. }          # exclude ENTREPRISES
MINUS { ?item (wdt:P31/wdt:P279*) wd:Q15893266. }         # exclude old entities
MINUS { ?item wdt:P576 _:b2. }                            # remove items with P576 (dissolved, abolished or demolished) as a main property
FILTER( ?sLat < ?lat && ?lat < ?nLat ) . #it's here that filter inside the south and north bounds
FILTER( ?wLon < ?lon && ?lon < ?eLon ) .#it's here that filter inside the east, west bounds
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v21("?Globe") v18("?cValue") v17("?coord"):::projected v8("?country"):::projected v3("?eLon") v14("?eValue") v13("?east") v20("?globe") v19("?item"):::projected v5("?lat") v2("?lon") v6("?nLat") v10("?nValue") v9("?north") v4("?sLat") v12("?sValue") v11("?south") v1("?wLon") v16("?wValue") v15("?west") a1((" ")) a2((" ")) a3((" ")) a4((" ")) a5((" ")) a7((" ")) a8((" ")) a6((" ")) a9((" ")) c26(["wd:Q15893266"]):::iri c25(["wd:Q4830453"]):::iri c17(["wikibase:BestRank"]):::iri f0[["?wLon < ?lon?lon < ?eLon"]] f0 --> v1 f0 --> v2 f0 --> v3 f1[["?sLat < ?lat?lat < ?nLat"]] f1 --> v4 f1 --> v5 f1 --> v6 f2[["?Globe = 'wd:Q2'"]] f2 --> v21 bind3[/VALUES ?country/] bind3-->v8 bind30(["wd:Q1050"]) bind30 --> bind3 a1 --"p:statement/P1332"--> v9 a1 --"p:statement/value/P1332"--> v10 v8 --"p:P1332"--> a1 a2 --"p:statement/P1333"--> v11 a2 --"p:statement/value/P1333"--> v12 v8 --"p:P1333"--> a2 a3 --"p:statement/P1334"--> v13 a3 --"p:statement/value/P1334"--> v14 v8 --"p:P1334"--> a3 a4 --"p:statement/P1335"--> v15 a4 --"p:statement/value/P1335"--> v16 v8 --"p:P1335"--> a4 v10 --"wikibase:geoLatitude"--> v6 v12 --"wikibase:geoLatitude"--> v4 v14 --"wikibase:geoLongitude"--> v3 v16 --"wikibase:geoLongitude"--> v1 a5 --"a"--> c17 a5 --"p:statement/P625"--> v17 a5 --"p:statement/value/P625"--> v18 v19 --"p:P625"--> a5 v18 --"wikibase:geoLatitude"--> v5 v18 --"wikibase:geoLongitude"--> v2 v18 --"wikibase:geoGlobe"--> v20 bind4[/"?globe'wd:Q2'"/] v20 --o bind4 bind4 --as--o v21 subgraph minus5["MINUS"] style minus5 stroke-width:6px,fill:pink,stroke:red; v19 --"p:direct/P17"--> a6 end subgraph minus6["MINUS"] style minus6 stroke-width:6px,fill:pink,stroke:red; v19 --"p:direct/P31"--> a7 a7 --"p:direct/P279"--> c25 end subgraph minus7["MINUS"] style minus7 stroke-width:6px,fill:pink,stroke:red; v19 --"p:direct/P31"--> a8 a8 --"p:direct/P279"--> c26 end subgraph minus8["MINUS"] style minus8 stroke-width:6px,fill:pink,stroke:red; v19 --"p:direct/P576"--> a9 end