0

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
kaleidoscop
  • 113
  • 5
  • `SELECT ?id ?idLabel ?parentId ?birthDate ?country ?countryLabel ?enArticle {{SELECT ?id ?parentId ?birthDate ?country ?enArticle (sample(?achievement) as ?achievement) (sample(?pic) as ?pic) WHERE { ?id wdt:P106 wd:Q170790. ` – UninformedUser Dec 10 '20 at 15:31
  • `?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 .} OPTIONAL{ ?id wdt:P1066|wdt:P184 ?parentId. ?parentId wdt:P106 wd:Q170790. ?parentId wdt:P800|wdt:P166 ?parentNotableWork. } OPTIONAL { ?id wdt:P18 ?pic } } GROUP BY ?id ?idLabel ?parentId ?birthDate ?country ?countryLabel ?enArticle} SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } }` – UninformedUser Dec 10 '20 at 15:31
  • Alright, works perfect, thanks! So it seems you did a "sub-SELECT" instruction, could you explain the logic of that, or point me towards a ressource? I'm very newbie here – kaleidoscop Dec 10 '20 at 15:43
  • On the other hand, the ?pic information has disappeared... – kaleidoscop Dec 10 '20 at 15:51
  • my bad, I forgot to select them in the outer query: `SELECT ?id ?idLabel ?parentId ?birthDate ?country ?countryLabel ?enArticle ?pic ?achievement` – UninformedUser Dec 11 '20 at 06:47

0 Answers0