Search code examples
rdfsparqlsemantic-webdbpedia

Sparql query times out with a transitive temp memory error message


I am running the following query to get visitor attraction in Italy

select distinct ?poi where {?company a dbpedia-owl:Place ; rdfs:label ?poiName; dcterms:subject/skos:broader* category:Visitor_attractions_in_Italy } 

But I get the following error.

Virtuoso 42000 Error TN...: Exceeded 1000000000 bytes in transitive temp memory. use t_distinct, t_max or more T_MAX_memory options to limit the search or increase the pool SPARQL query: define sql:big-data-const 0 #output-format:application/sparql-results+json define input:default-graph-uri PREFIX owl: PREFIX xsd: PREFIX rdfs: PREFIX rdf: PREFIX foaf: PREFIX dc: PREFIX : PREFIX dbpedia2: PREFIX dbpedia: PREFIX skos: select distinct ?poi where {?company a dbpedia-owl:Place ; rdfs:label ?poiName; dcterms:subject/skos:broader* category:Visitor_attractions_in_Italy }

I get this Error even If i use limit 10 at the end of the query. I know this may be a time consuming query but not sure how to break this query down such that at the end I get all the visitor attractions.


Solution

  • Someone ran into this same type of problem and asked about it on answers.semanticweb.com: Finding all possible categories between one given and Main classification with DBpedia and SPARQL. The somewhat unsatisfying answer provided there is the answer here, too: make a decision about how deep you actually need to go, and rather than using *, use the {} notation to indicate a maximum number of repetitions of skos:broader. E.g.,

    select distinct ?poi where {
      ?poi a dbpedia-owl:Place ;
           dcterms:subject/skos:broader{,10} category:Visitor_attractions_in_Italy
    } 
    

    SPARQL results

    The {} notation to indicate number of repetitions is actually not a part of the standard, though it was in earlier drafts of it. The DBpedia endpoint, which is based on Virtuoso, still supports it, though.