The hint:Prior optimization on the property path might help a bit?

 

https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/query_optimization#h-Property_paths-Optimization_strategies

 

https://w.wiki/4Jas

 

Jeff

 

From: Thad Guidry <thadguidry@gmail.com>
Date: Friday, October 29, 2021 at 10:12 AM
To: David Causse <dcausse@wikimedia.org>, Discussion list for the Wikidata project. <wikidata@lists.wikimedia.org>, stevenliuyi@gmail.com <stevenliuyi@gmail.com>
Subject: [External] [Wikidata] Help make this Property Query faster

Hi David and team,

 

In Yi Liu's tool, Wikidata Property Explorer, I noticed that the query performance could be better ideally.  Currently the query takes about 9 seconds and I'm asking if there might be anything to help reduce that considerably?  Refactoring query for optimization, backend changes, anything you can think of Davd?

SELECT DISTINCT ?prop ?label ?desc ?type (GROUP_CONCAT(DISTINCT ?alias; SEPARATOR = " | ") AS ?aliases) WHERE {
  ?prop (wdt:P31/(wdt:P279*)) wd:Q18616576;
    wikibase:propertyType ?type.
  OPTIONAL {
    ?prop rdfs:label ?label.
    FILTER((LANG(?label)) = "en")
  }
  OPTIONAL {
    ?prop schema:description ?desc.
    FILTER((LANG(?desc)) = "en")
  }
  OPTIONAL {
    ?prop skos:altLabel ?alias.
    FILTER((LANG(?alias)) = "en")
  }
}
GROUP BY ?prop ?label ?desc ?type