title: Jena: How to infer data / performance issues
body: <p>I'd like to use Jena's inference capabilities, but I'm having some performance problems when I am using InfModel. </p>
  
  <p>Here's a simplified overview of my ontology: </p>
  
  <p>Properties: </p>
  
  <pre><code>hasX            (Ranges(intersection): X, inverse properties: isXOf)
  |-- hasSpecialX (Ranges(intersection): X, inverse properties: isSpecialXOf)
  
  isXOf           (Domains(intersection): X, inverse properties: hasX)
  |--isSpecialXOf (Domains(intersection): X, inverse properties: hasSpecialX)
  </code></pre>
  
  <p>Furthermore there's a class 'Object':</p>
  
  <pre><code>Object hasSpecialX some X
  </code></pre>
  
  <p>Explicitly stored is the following data: </p>
  
  <pre><code>SomeObject a Object 
  SomeX a X
  SomeObject hasSpecialX SomeX  
  </code></pre>
  
  <p>Using the following query I'd like to determine to which class an instance belongs. According to the assumptions made, only 'SomeObject' should be returned. </p>
  
  <pre><code>SELECT ?x WHERE { ?x :hasX :SomeX . } 
  </code></pre>
  
  <p>However, querying against <code>ds.getDefaultModel()</code> doesn't work, because the data isn't stored explicitly. When I'm using <code>infModel</code> on the other hand, the query never finishes. At the longest I've been waiting for 25 minutes before aborting. (The triplestore has a size of about 180 MB)</p>
  
  <p>This is my code: </p>
  
  <pre><code>OntModel ont = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_MICRO_RULE_INF, null); 
  ont.read("file:..." , "RDF/XML"); 
  
  Reasoner reasoner = ReasonerRegistry.getOWLMicroReasoner(); 
  reasoner = reasoner.bindSchema(ont); 
  
  Dataset dataset = TDBFactory.createDataset(...); 
  Model model = dataset.getDefaultModel(); 
  
  InfModel infModel = ModelFactory.createInfModel(reasoner, model);
  
  QueryExecution qe = null;
  ResultSet rs;
  
  try {
      String qry = "SELECT ?x WHERE { ?x :hasX :SomeX . }"; 
      qe = QueryExecutionFactory.create(qry, infModel); 
      rs = qe.execSelect(); 
  
      while(rs.hasNext()) {
          QuerySolution sol = rs.nextSolution(); 
          System.out.println(sol.get("x"));
      }
  } finally {
      qe.close();
      infModel.close();
      model.close(); 
      dataset.close();
  }
  </code></pre>
  
  <p>Is there anything wrong with the code above, or what else could be the reason it doesn't work? </p>
  
  <p>Beside that, I'd like to know if I can increase the performance if I do 'Export inferred axioms as ontology' (as provided by Protege)? </p>
  
  <p><b>EDIT:</b>
  I the meantime I've tried to use Pellet, but still I can't get an inferred model, as I've described in my other question: <a href="https://stackoverflow.com/questions/10279894/outofmemoryerror-using-pellet-as-reasoner">OutOfMemoryError using Pellet as Reasoner</a>. So what else can I do?</p>