Reasoning query performance

I've been wanting to ask this question for a while. I generally assume that queries with reasoning enabled will take longer than the same query without reasoning but is that a reasonable assumption? I haven't tested it but is it conceivable that there could be a circumstance that would enable a query with reasoning to outperform one without?

Stardog implements the "pay-as-you-go" approach to reasoning. This means the reasoning performance should be no more than required to answer the query that you've posed. The more complex your reasoning schema, the more Stardog must do to compute inferences at query time. In general, there is a cost computing these inferences at query time. It may be possible to formulate a query which, due to reasoning-specific optimizations, runs faster with reasoning but it's usually not the case.

A (contrived) example where a reasoning query might be faster would be something like this:

select * {
   ?person a :Person .
   ?person :worksFor ?org .
   ?org a :Organization
}

where in the schema we have:

:worksFor rdfs:domain :Person ; 
          rdfs:range :Organization

The reasoner would make use of the schema information to simplify the query to a single triple pattern (?person :worksFor ?org) since the domain and range definitions make the other triple patterns trivially true. So the query plan would have a single scan instead of three scans. How much improvement this would yield or how likely this would happen in practice is debatable.

Best,
Evren

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.