I have a Wikidata query that times out, and I think it could be optimised. I trie to include a "Hint" but it seems I don't include it properly because it does not improve the time (but it should!)
EDIT: What follows is valid but I realised the line "?id wdt:P27 ?country" which only serves to determine the country is more crucial regarding time (20s without it, 1min or timeout with it)
So basically I'm looking for mathematicians who had an achivement (notable work or award) and whose advisor/professor also. The weird thing is that (for instance) when I specify that the advisor should have an achievement, it much raises the time, when it should pretty straightforward to check wether it has an achievement or not once it has been found...
SELECT ?id ?idLabel ?parentId ?birthDate ?country ?countryLabel ?enArticle (SAMPLE(?achievement) as ?achievement) (SAMPLE(?pic) as ?pic)#random pic, random student
WHERE
{
?id wdt:P106 wd:Q170790. #occupation is mathematician
?id wdt:P800|wdt:P166 ?achievement.
?id wdt:P27 ?country.
OPTIONAL{?id wdt:P569 ?birthDate.}
OPTIONAL{ ?enArticle schema:about ?id .#et un article wiki US
?enArticle schema:isPartOf <https://en.wikipedia.org/>.}
OPTIONAL{ ?id wdt:P1066|wdt:P184 ?parentId.#student of
?parentId wdt:P106 wd:Q170790.#parent is mathematician
?parentId wdt:P800|wdt:P166 ?parentNotableWork.
hint:Prior hint:gearing "forward".
}
OPTIONAL { ?id wdt:P18 ?pic }#on prend une image
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }#en anglais
}
GROUP BY ?id ?idLabel ?parentId ?birthDate ?country ?countryLabel ?enArticle #pour results qui ont la meme image