Search code examples
sparqldbpediavirtuoso

Japanese Virtuoso SPARQL EndPoint times out very quickly


I am trying to use the following query on Japanese dbpedia SPARQL Endpoint

select ?s  (group_concat(?album_ja ; separator = "|") AS ?name_album_ja_csv)  where{
   values ?sType { dbpedia-owl:Song
                       dbpedia-owl:Single
    } .
      ?s a ?sType .
      ?s (dbpedia-owl:album|^dbpedia-owl:album)* ?albums;rdfs:label ?album_ja      
    }group by ?s order by ?s offset 0 limit 10

but I get this error Virtuoso 42000 Error The estimated execution time 1005 (sec) exceeds the limit of 400 (sec). Almost any query involving group by has this problem. Is this a server problem? Is my query inefficient? How can I get around it?


Solution

  • I'm not sure exactly what you're trying to do, but since ?o isn't used in the results, you can get rid of it. Even after you do that, though, you'll still have the same problem. You need to change the property path somehow. I don't think that you actually need arbitrary length paths in both directions. You could use ? instead of * to say "path of length 0 or 1" and thus:

    select ?s
           (group_concat(?album_ja ; separator = "|") AS ?name_album_ja_csv)
    where {
      values ?sType { dbpedia-owl:Song dbpedia-owl:Single }
      ?s a ?sType .
      ?s (dbpedia-owl:album|^dbpedia-owl:album)? ?album_ja      
    }
    group by ?s
    limit 100
    

    SPARQL results

    Note that a path of length 0 is going to be a link to itself, so one value of ?album_ja is always going to be the same as ?s. Is this really what you want?