this seems to be relatively simple, to query the date of birth of Barack Obama, why does it take so long that it timeout at https://query.wikidata.org/ ? There are only about 3 entity that has label Barack Obama and also about 2 for "date of birth"
SELECT DISTINCT ?ent ?wdtProperty ?val ?valLabel WHERE {
?ent rdfs:label|skos:altLabel "Barack Obama"@en.
?wdProperty1 rdfs:label|skos:altLabel "date of birth"@en;
wikibase:directClaim ?wdtProperty1.
?ent ?wdtProperty1 ?val .
} LIMIT 10
The correct answer to this is
SELECT DISTINCT ?ent ?wdtProperty1 ?val
WITH
{
SELECT ?wdtProperty1
WHERE
{
[] rdfs:label|skos:altLabel "date of birth"@en;
wikibase:directClaim ?wdtProperty1.
}
} AS %get_predicate
WITH
{
SELECT ?ent
WHERE
{
?ent rdfs:label|skos:altLabel "Barack Obama"@en.
}
} AS %get_subject
WHERE
{
INCLUDE %get_predicate
INCLUDE %get_subject
?ent ?wdtProperty1 ?val .
}
Thanks to https://www.wikidata.org/wiki/Wikidata:Request_a_query#Slow_query_on_label