Wikidata query timeout
Asked Answered
P

1

8

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.

Premonitory answered 31/1, 2017 at 23:13 Comment(1)
For example.Cherianne
P
2

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

Panslavism answered 8/5, 2019 at 23:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.