query-79d0bb402c59b0932c59f8008d791725

rq turtle/ttl

14:03, 4 May 2024 (UTC)) talk (ShismaIn both cases I'm only looking url statements that point to these urls. can I make both queries fast while yielding the same results? –sounds reasonable since this query is much faster 15:21, 4 May 2024 (UTC)) talk (InfrastrukturI think it matches the basic graph pattern ?s schema:isPartOf https://en.wikipedia.org/ that the sitelinks use. 15:13, 4 May 2024 (UTC)) talk (Shismainteresting. the hint, makes the second query faster, but the first query becomes slower. since I'm generating these queries programmaticaly I would need a heuristic to decide whether the hint should be present or not. why does the second query it start with a set of 9.8M items in the first place? I assume there aren't 9.8M statements with these urls… are there? – 14:58, 4 May 2024 (UTC)) talk (InfrastrukturSome times the optimizer makes bad guesses about which order to do things. It's been said that starting with small sets gives good performance, but really what you want is to keep the size of the intermediate joins small throughout the query and especially at the start. Here it will run things in order of appearance. For your first query it will start with a set of 2 items and combine with a set of 11K items, where on the second query it will start with a set of 9.8M items, then it will combine this with a second set of 11K items. To fix the second query you can replace the last line with "?property wikibase:directClaim ?predicate. hint:Prior hint:runFirst true .".

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
SELECT ?url ?item WHERE {
  VALUES ?url {
    <https://en.wikipedia.org/wiki/Double_bond>
    <https://en.wikipedia.org/wiki/Double_bond/>
    <http://en.wikipedia.org/wiki/Double_bond>
    <http://en.wikipedia.org/wiki/Double_bond/>
    #<https://en.wikipedia.org/>
    <http://en.wikipedia.org/>
    <https://en.wikipedia.org>
    <http://en.wikipedia.org>
  }
  ?item ?predicate ?url.
  ?property wikibase:directClaim ?predicate.
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v2("?item"):::projected v3("?predicate") v4("?property") v1("?url"):::projected bind0[/VALUES ?url/] bind0-->v1 bind00([https://en.wikipedia.org/wiki/Double_bond]) bind00 --> bind0 bind01([https://en.wikipedia.org/wiki/Double_bond/]) bind01 --> bind0 bind02([http://en.wikipedia.org/wiki/Double_bond]) bind02 --> bind0 bind03([http://en.wikipedia.org/wiki/Double_bond/]) bind03 --> bind0 bind04([http://en.wikipedia.org/]) bind04 --> bind0 bind05([https://en.wikipedia.org]) bind05 --> bind0 bind06([http://en.wikipedia.org]) bind06 --> bind0 v2 -->v3--> v1 v4 --"wikibase:directClaim"--> v3