query-b10cda0e7d9a2dc2deb945c417b69732

rq turtle/ttl

Query optimization (milestones) 13:39, 8 June 2019 (UTC) Jura (currently 470000 items)? It works up to 400000. --- Q142How it could be made to work for

Use at

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
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#>
#defaultView:LineChart
SELECT (SAMPLE(?date) AS ?date) (SUM(?count) AS ?cumulative_count) ?milestone
{

  { SELECT ?qid_rounded (count(?item) AS ?count) (SAMPLE(?item) AS ?exampleitem) WHERE {
      ?item wdt:P17 wd:Q142  .
      BIND( xsd:integer( substr(str(?item), 33)) as ?qid)
      BIND(xsd:integer(?qid/20000) as ?qid_cut)
      BIND(?qid_cut*20000 as ?qid_rounded)

      #SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" } .
    }
    GROUP BY ?qid_rounded
  }
  wd:Q38074555 p:P1114 ?milestonep .
  ?milestonep ps:P1114 ?milestone .
  FILTER(?milestone > ?qid_rounded) .
  ?milestonep pq:P585 ?date .
}
GROUP BY ?milestone

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v6("?count"):::projected v10("?cumulative_count") v10("?date"):::projected v7("?exampleitem") v3("?item") v1("?milestone"):::projected v8("?milestonep") v4("?qid") v5("?qid_cut") v6("?qid_rounded") c3(["wd:Q38074555"]):::iri c2(["wd:Q142"]):::iri f0[["?milestone > ?qid_rounded"]] f0 --> v1 f0 --> v6 v3 --"p:direct/P17"--> c2 bind1[/"http://www.w3.org/2001/XMLSchema#integer(substring(str(?item),'33^^xsd:integer'))"/] v3 --o bind1 bind1 --as--o v4 bind2[/"http://www.w3.org/2001/XMLSchema#integer(?qid / '20000^^xsd:integer')"/] v4 --o bind2 bind2 --as--o v5 bind3[/"?qid_cut * '20000^^xsd:integer'"/] v5 --o bind3 bind3 --as--o v6 bind6[/"count(?item)"/] v3 --o bind6 bind6 --as--o v6 bind7[/"sample(?item)"/] v3 --o bind7 bind7 --as--o v7 c3 --"p:P1114"--> v8 v8 --"p:statement/P1114"--> v1 v8 --"p:qualifier/P585"--> v10 bind10[/"sample(?date)"/] v10 --o bind10 bind10 --as--o v10 bind11[/"sum(?count)"/] v6 --o bind11 bind11 --as--o v10