[fix] openstreetmap engine: optmizer SPARQL query

add
hint:Query hint:optimizer "None".
to the SPARQL query to keep the response time small.

It tells the optimizer to follow the path from ?item to the different property values
instead of the other way around.
See https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/query_optimization#Property_paths
This commit is contained in:
Alexandre Flament 2021-09-25 11:16:22 +02:00
parent 6f11b61cd5
commit ab569c1e12
1 changed files with 1 additions and 0 deletions

View File

@ -42,6 +42,7 @@ route_re = re.compile('(?:from )?(.+) to (.+)')
wikidata_image_sparql = """ wikidata_image_sparql = """
select ?item ?itemLabel ?image ?sign ?symbol ?website ?wikipediaName select ?item ?itemLabel ?image ?sign ?symbol ?website ?wikipediaName
where { where {
hint:Query hint:optimizer "None".
values ?item { %WIKIDATA_IDS% } values ?item { %WIKIDATA_IDS% }
OPTIONAL { ?item wdt:P18|wdt:P8517|wdt:P4291|wdt:P5252|wdt:P3451|wdt:P4640|wdt:P5775|wdt:P2716|wdt:P1801|wdt:P4896 ?image } OPTIONAL { ?item wdt:P18|wdt:P8517|wdt:P4291|wdt:P5252|wdt:P3451|wdt:P4640|wdt:P5775|wdt:P2716|wdt:P1801|wdt:P4896 ?image }
OPTIONAL { ?item wdt:P1766|wdt:P8505|wdt:P8667 ?sign } OPTIONAL { ?item wdt:P1766|wdt:P8505|wdt:P8667 ?sign }