login about faq

I get "SR171: Transaction timed out" on the dbpedia sparql endpoint, for the following simple query: Why do I get this error? I don't set any timeout - it's on 0.

PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX : <http://dbpedia.org/resource/>
PREFIX dbpedia2: <http://dbpedia.org/property/>
PREFIX dbpedia: <http://dbpedia.org/>

PREFIX ont: <http://dbpedia.org/ontology/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name ?date (bif:substring(STR(?date), 1, 4) AS ?year) WHERE {
   ?person ont:birthDate ?date .
   ?person foaf:name ?name

   . FILTER ( (fn:string-length(STR(?date)) = 10) && (bif:substring(STR(?date), 9, 2) = '05') && (bif:substring(STR(?date), 6, 2) = '02') && (?date > "1868-01-01"^^xsd:date) && (?date < "2005-01-01"^^xsd:date) )

asked Feb 07 at 08:03

paulrusu's gravatar image

paulrusu
212

edited Feb 07 at 08:28


Here is Your Sparql Query as URL to the DbPedia sparql endpoint. Which just seems to work. Maybe there was a temporary overload of the system that made it timeout, or maybe you have to add additional information on how you operate your query?

answered Feb 07 at 11:27

Gerrit%20V's gravatar image

Gerrit V
93117

Beat me to it ;)

(Feb 07 at 11:29) Signified ♦ Signified's gravatar image

It's because your query is too hard for the DBPedia endpoint to answer without adversely impacting other users of the service.

As DBPedia is a well known public SPARQL endpoint it gets very heavily used so the people who host it have it configured to impose strict limits on how long a query can run for so that rogue users don't make the service unusable for others.

In your case your query will take a long time because you ask something that has a lot of initial results (592299 to be precise) and then apply a FILTER over it. FILTER is quite expensive in SPARQL especially when doing string manipulation and date comparison. AFAIK the DBPedia timeout is something fairly low like a few seconds and the endpoint simply cannot finish your query within that time because it takes too long to apply the FILTER.

Note - Here's the query I used to see how many results the first portion of your query was returning:

PREFIX ont: <http://dbpedia.org/ontology/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>

SELECT COUNT(*) 
WHERE 
{
   ?person ont:birthDate ?date .
   ?person foaf:name ?name   
}

answered Feb 07 at 15:48

Rob%20Vesse's gravatar image

Rob Vesse ♦
8.6k515

is there any way to increase the DBpedia timeout in order to be able to make Queries that takes long time ?

(Feb 11 at 14:57) Hady Elsahar Hady%20Elsahar's gravatar image

If you really want to have fun with DBpedia, you need to load it into your own triple store.

If you've got a machine with an above-average amount of memory (like my 24GB Windows workstation or a high-memory extas large instance in the AMZN cloud) it's pretty easy to load DBpedia into the open source edition of Virtuoso -- the DBpedia public endpoint uses the commercial version of the same software, so you should get very much the same results.

I've loaded data sets of similar size into an 8GB laptop and had success, although the loading takes most of a day.

DBpedia has some anomalies and Virtuoso is more tolerant of broken RDF than some other products, so you might have some challenges with other triple stores. I know Ontotext has a special edition of DBpedia that has been cleaned to work with OWLIM-SE.

Note also that the version of DBpedia in the public endpoint is incomplete: it lacks the "Wikipedia pagelinks" data set, which I find particularly fruitful.

answered Feb 09 at 10:09

database_animal's gravatar image

database_animal
6.6k410

I guess missing the trailing } is just a typo?

Your query is quite expensive, requiring to check through the birthdates of all people in Wikipedia and apply the filter you specify, hitting less that 1-in-365 persons.

Try starting with a LIMIT 1 and see from there. This works for me, and should now be cached:

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX ont: <http://dbpedia.org/ontology/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>

SELECT ?name ?date (bif:substring(STR(?date), 1, 4) AS ?year) WHERE {

   ?person ont:birthDate ?date .
   ?person foaf:name ?name .

   FILTER ( (fn:string-length(STR(?date)) = 10)  && (bif:substring(STR(?date), 9, 2) = '05')  && (bif:substring(STR(?date), 6, 2) = '02') && (?date > "1868-01-01"^^xsd:date) && (?date < "2005-01-01"^^xsd:date) )
}
LIMIT 10

Increment the limit or fiddle with the range (as a cheap version of "offset") until you're happy with the answers you get.

answered Feb 07 at 11:29

Signified's gravatar image

Signified ♦
15.8k522

*heads off to see what famous people shares his birthday*

(Feb 07 at 11:31) Signified ♦ Signified's gravatar image

Gerrit V: I run the query from the browser (FF) with the http://dbpedia.org/sparql interface and it gives the timeout error. Even a simple Querida like the one below ( i didn't include the namespaces-they are the same as above) with LIMIT 1 gives timeout. I also run the query from PHP - (wich is where i want to use it ultimately). But the query results are the same in the browser as from PHP. So it either works/doesn't work in both.

Gerrit V: yes the problem is that dbpedia's system is overloaded. The query works late at night or in the morning (i'm in Romania Eastern Europe). It doesn't work in the rest of the time. This is not acceptable for the website of course.

Signified: Using LIMIT 1 to limit the answers is probably a good idea. However on my system and from my hosting's system it doesn't work even with LIMIT 1 (-> one). I still get the timeout error.

Wikipedia works with a lot less money than other sites so I think this is why their system is so limited. I don't think there is much I can do. I have to give up on this DBPedia related features wich is too bad, but I don't think there's much I can do. If anyone has sugestions I am happy to try them out. Thank you all for your answers.

Yes the problem is that dbpedia's system is overloaded. What is interesting is that it hardly takes 1-2 seconds for the query to execute and i see the error. DB Pedia could allow at least 2-3 seconds for a query. I'm not sure why they don't. The query works late at night or in the morning (i'm in Romania Eastern Europe). It doesn't work in the rest of the time. This is not acceptable for the website of course. I have a question though: Does it work from anyone's system at usual hours? Please try and tell me. Thanks

SELECT ?name ?date (bif:substring(STR(?date), 1, 4) AS ?year) 
WHERE {

?person ont:birthDate ?date . 
?person foaf:name ?name 
. FILTER ( (fn:string-length(STR(?date)) = 10) && (bif:substring(STR(?date), 9, 2) = bif:substring('05', 1, 2))) 
} 
LIMIT 1

answered Feb 09 at 09:04

paulrusu's gravatar image

paulrusu
212

edited Feb 09 at 09:13

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×593
×120
×61

Asked: Feb 07 at 08:03

Seen: 453 times

Last updated: Feb 11 at 14:57