query-5ca35872af19d7946db9de7f143402f2

rq turtle/ttl

08:13, 23 February 2023 (UTC)) talk (Ordercrazy : zwei Stern-Operatoren in einer Abfrage führen häufig in einen Timeout. Eine Alternative bietet beispielsweise eine Liste von konkreten Objekten mit UNION verbunden: OrdercrazyHallo @

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?GKZ ?bürgermeisterLabel
WHERE {
        { ?item wdt:P31 wd:Q515 . } UNION { ?item wdt:P31 wd:Q15284 . } # Städte und Gemeinden in Bayern
        { ?item wdt:P131* wd:Q980. }             # in Bayern
  OPTIONAL { ?item p:P6 ?statement .
             ?statement ps:P6 ?bürgermeister .
             ?statement pq:P580 ?start .
           }
  OPTIONAL { ?item wdt:P439 ?GKZ . }    # Gemeindekennzahl
  SERVICE wikibase:label { bd:serviceParam wikibase:language "de" }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?GKZ"):::projected v3("?bürgermeister") v1("?item"):::projected v4("?start") v2("?statement") c13(["de"]):::literal c3(["wd:Q15284"]):::iri c11(["bd:serviceParam"]):::iri c2(["wd:Q515"]):::iri c5(["wd:Q980"]):::iri subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v1 --"p:direct/P31"--> c3 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v1 --"p:direct/P31"--> c2 end union0r <== or ==> union0l end v1 --"p:direct/P131"--> c5 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v1 -."p:P6".-> v2 v2 --"p:statement/P6"--> v3 v2 --"p:qualifier/P580"--> v4 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v1 -."p:direct/P439".-> v5 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c11 --"wikibase:language"--> c13 end