Title: How to persist auto-generated OWL rules or at least not hold them all in memory at once?
Tags: sparql;jena;graph-databases;fuseki;reasoner
Question: I have a data set with about 9 million triples in it and the owl reasoner enabled.

When the first sparql query is sent I get a seemingly endless stream of lines in the log file that look similar this:

```Adding rule [ (<http://example.org/cat3&gt; ?P ?V) -&gt;(<http://example.org/cat2&gt; ?P ?V) ]
```

These lines keep appearing until my JVM runs out of memory and the fuseki server stops functioning. 

Working with a smaller data set, I can see that the rules are only generated once. Subsequent queries do not re-log the creation of these rules, unless I bounce the server process.

Is there a way to generate these rules only once and have them persisted in the database? Or some other way to avoid loading them all into memory at once? 

I very much appreciate any help I can get.

Comment: the phrase "generate rules" is a bit misleading. What do you mean by this? The idea should be to materialize the triples inferred by a reasoner. Your whole setup would be interesting to know. Which reasoner? Which Fuseki version. And then you could think about whether you need the reasoning profile that you"re using

Comment: The `OWLMicroFBRuleReasoner` reasoner just supports RDFS plus the various property axioms, `intersectionOf`, `unionOf` (partial) and `hasValue`. It omits the cardinality restrictions (`owl:minCardinality, owl:maxCardinality, owl:cardinality`) and equality axioms (e.g. `owl:sameAs, owl:differentFrom, owl:distinctMembers`) as well as property restrictions `owl:someValuesFrom, owl:allValuesFrom`, which enables it to achieve much higher performance.

Comment: And yes, you have to write the materialized triples once to the triple store. That would allow to disable the reasoner for later querying and you can directly execute queries on the inferred RDF graph.

Comment: Thanks. I switched the reasoner from OWLFBRuleReasoner to OWLMicroFBRuleReasoner and this seems to have fixed the issue. I don't understand the limitations of the "micro" reasoner, so I don't know if it will suffice for our needs or not. All I meant by generating rules was that I see log lines like the above appear. My assumption was it's figuring out the things it needs to do reasoning. I see none of those "adding rule" log lines if the reasoner is disabled. It maybe it's materializing triples but it's not storing them - it re-materializes them when fuseki is restarted. Fuseki version 3.10

Comment: How do you write them to the triple store?



{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 0, 'CommentCount': 5, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2019:00:03/12/19', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<sparql><jena><graph-databases><fuseki><reasoner>', 'Title': 'How to persist auto-generated OWL rules or at least not hold them all in memory at once?', 'ViewCount': 54, 'id': 55126235, 'user_AboutMe': None, 'user_AccountId': 11256831.0, 'user_DisplayName': 'Roman', 'user_Reputation': 21.0, 'user_Views': 2.0, 'user_id': 8256309.0}}