Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wikidata query timeout

I wanted to add the instance of property to this example query to get only items which are an instance of human.

This is the example query:

SELECT ?entityLabel (YEAR(?date) as ?year) 
WHERE
{
    BIND(MONTH(NOW()) AS ?nowMonth)
    BIND(DAY(NOW()) AS ?nowDay)

    ?entity wdt:P569 ?date .
    FILTER (MONTH(?date) = ?nowMonth && DAY(?date) = ?nowDay)
    SERVICE wikibase:label {
        bd:serviceParam wikibase:language "en" .
    }
}
LIMIT 10

And this my adjusted version with the instance of property:

SELECT ?entityLabel (YEAR(?date) as ?year) 
WHERE
{
    ?entity wdt:P31 wd:Q5 .

    BIND(MONTH(NOW()) AS ?nowMonth)
    BIND(DAY(NOW()) AS ?nowDay)

    ?entity wdt:P569 ?date .
    FILTER (MONTH(?date) = ?nowMonth && DAY(?date) = ?nowDay)
    SERVICE wikibase:label {
        bd:serviceParam wikibase:language "en" .
    }
}
LIMIT 10

But also I added just the one line I now get a query timeout. Does anyone know how I cloud improve my query so that I don't get a timeout.

like image 557
user128574 Avatar asked Jan 31 '17 23:01

user128574


Video Answer


1 Answers

This will time out because the query service will attempt to start with all wdt:P31 wd:Q5 before limiting them.

You can see more details in: https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/query_optimization

like image 79
Pablo Busatto Avatar answered Oct 14 '22 22:10

Pablo Busatto