query-123d2f3c9a8ad356133399ac833263e2

rq turtle/ttl

Missing articles in language - optimizationMy SPARQL has gone a little bit bad because I've used only very simple ones in last months. Could somebody optimize this one? Probably subqery wouldn't hurt here:

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item (SAMPLE(?enwiki) AS ?enwiki) (COUNT(?wpSitelink) as ?sitelinks) WHERE {
    ?item wdt:P1435 wd:Q9259 .
  ?wpSitelink schema:isPartOf [ wikibase:wikiGroup "wikipedia" ];
                     # schema:inLanguage ?wpLanguage;
                      schema:about ?item.
  filter not exists {  ?lvwiki schema:about ?item; schema:isPartOf <https://lv.wikipedia.org/> .}
  optional {  ?enwiki schema:about ?item; schema:isPartOf <https://en.wikipedia.org/> .}
    #SERVICE wikibase:label { bd:serviceParam wikibase:language "en,de,fr,pl,ru" }
}
group by ?item
ORDER BY DESC(?sitelinks)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v6("?enwiki"):::projected v3("?item"):::projected v2("?lvwiki") v6("?sitelinks") v4("?wpSitelink"):::projected a1((" ")) c8([https://en.wikipedia.org/]):::iri c3([https://lv.wikipedia.org/]):::iri c7(["wikipedia"]):::literal c5(["wd:Q9259"]):::iri f0[["not "]] subgraph f0e0["Exists Clause"] e0v1 --"schema:about"--> e0v2 e0v1 --"schema:isPartOf"--> e0c3 e0v2("?item"):::projected e0v1("?lvwiki"):::projected e0c3([https://lv.wikipedia.org/]):::iri end f0--EXISTS--> f0e0 f0 --> v2 f0 --> c1 f0 --> v3 f0 --> c2 f0 --> c3 v2 --"schema:about"--> v3 v2 --"schema:isPartOf"--> c3 v3 --"wdt:P1435"--> c5 a1 --"wikibase:wikiGroup"--> c7 v4 --"schema:isPartOf"--> a1 v4 --"schema:about"--> v3 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v6 -."schema:about".-> v3 v6 --"schema:isPartOf"--> c8 end bind3[/"sample(?enwiki)"/] v6 --o bind3 bind3 --as--o v6 bind4[/"count(?wpSitelink)"/] v4 --o bind4 bind4 --as--o v6