为什么这个 Wikidata sparql 会超时?
Why does this Wikidata sparql timeout?
这个貌似比较简单,查询奥巴马的生日,为什么要这么久,到https://query.wikidata.org/超时了?只有大约 3 个实体带有巴拉克奥巴马标签,还有大约 2 个带有“出生日期”
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
正确答案是
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 .
}
感谢https://www.wikidata.org/wiki/Wikidata:Request_a_query#Slow_query_on_label
这个貌似比较简单,查询奥巴马的生日,为什么要这么久,到https://query.wikidata.org/超时了?只有大约 3 个实体带有巴拉克奥巴马标签,还有大约 2 个带有“出生日期”
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
正确答案是
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 .
}
感谢https://www.wikidata.org/wiki/Wikidata:Request_a_query#Slow_query_on_label