Alex Boyarintsev
Alex Boyarintsev

Reputation: 135

SPARQL performance in property path query Sesame / rdf4j

Let's say I want to find all subjects which are connected with objects via property path. The connection could be represented:

Subject - prop 1 -> A - prop 2 -> B - prop 3 -> Object

This could be achieved by quite simple SPARQL query:

SELECT ?s WHERE {
    ?s prop1/prop2/prop3 ?o .
    VALUES ?o { <uri1> ... <urin> }
}

But I also want to include paths which use subclasses of A and/or B:

Subject - prop 1 -> subclassOfA - prop 2 -> subclassOfB - prop 3 -> Object

To achieve this I've added intermediate "sublassOf" property into the the path:

SELECT ?s WHERE {
    ?s prop1/<subclassOf>*/prop2/<subclassOf>*/prop3 ?o .
    VALUES ?o { <uri1> ... <urin> }
}

This worked really fast on my dataset in Sesame 2.7.2, but after migrating to rdf4j 2.5.2 this query just hangs. The question is whether this is the correct way of querying this way or there's something much more efficient? And what could've caused such a significant performance drop in the new versions?

Upvotes: 1

Views: 172

Answers (0)

Related Questions