> On 01 Feb 2016, at 13:49, Andy Seaborne <[email protected]> wrote:
> 
> On 01/02/16 12:11, Joël Kuiper wrote:
>> Hey all,
>> 
>> I’m trying to run a query to find the path to the root concept of a graph.
>> The entries are defined as rdfs:subClassOf
>> 
>> Currently I’m using
>> 
>> PREFIX skos: <http://www.w3.org/2004/02/skos/core# 
>> <http://www.w3.org/2004/02/skos/core#>>
>> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema# 
>> <http://www.w3.org/2000/01/rdf-schema#>>
>> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns# 
>> <http://www.w3.org/1999/02/22-rdf-syntax-ns#>>
>> 
>> SELECT ?parent ?label
>> WHERE {
>>  GRAPH ?g {
>>    ?concept rdfs:subClassOf* ?parent
>>  }}
>> 
>> However on a moderately sized data set < 1M triples, this query sometimes 
>> takes /minutes/.
>> I suspect it has to do with the disk-based TDB (since I hear my HDD spin a 
>> lot), but still.
>> Is there a way to optimise this query, maybe by using a different reasoner? 
>> And if so how would that reasoner be used!
>> 
>> Thanks in advance,
>> 
>> Joël
>> 
> 
> If you are using a reasoner and doing rdfs:subClassOf* then that is doing 
> excessive redundant work.
> 
> (Otherwise, with TDB is materialises more nodes that it needs to.)
> 
> The root is a node without a parent so this might help, without a reasoner:
> 
> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
> 
> SELECT ?top
> WHERE {
>   GRAPH ?g {
>     ?concept rdfs:subClassOf ?top
>     FILTER NOT EXISTS { ?top rdfs:subClassOf ?x }
>  }
> }
> 

I wasn’t using a reasoner yet (it’s just the bare Fuseki TDB assembler file). 
If I understand correctly your query does not allow the path of all the 
intermediate nodes to be found? 
E.g. A subclassOf B subclassOf C ….?

Thanks :-) 

Reply via email to