GraphDB System Statements

System statements are used as SPARQL pragmas specific to GraphDB. They are ways to alter the behaviour of SPARQL queries in specific ways. The IDs of system statements are not present in the repository in any way.

GraphDB System Statements can be recognized by their identifiers which begin either with the onto or the sys prefix. Those stand for <http://www.ontotext.com> and <http://www.ontotext.com/owlim/system#>, respectively.

System graphs

System graphs modify the result or change the dataset on which the query operates. The semantics used are identical to standard graphs - the FROM keyword. An example of graph usage would be:

PREFIX onto: <http://www.ontotext.com/>
SELECT * FROM onto:readwrite WHERE {
        ?s ?p ?o
}
  • onto:implicit - the graph contains statements inferred via the repository’s ruleset, located in the default graph.
  • onto:explicit - the graph contains statements inserted in the database by the user, located in the default graph.
  • onto:readonly - the graph contains schematic statements - i.e., the statements which define the repository’s ruleset.
  • onto:readwrite - the graph contains non-schematic statements - i.e., all statements beside the ones in the ruleset.
  • onto:count - a pseudo graph that forces a count of the results of the query and returns it as the result.
  • onto:disable-sameAs - a pseudo graph that disables the default behaviour of expanding the sameAs nodes of the query result.
  • onto:distinct - a pseudo graph that makes the query behave as if the DISTINCT keyword was used.
  • onto:skip-redundant-implicit - a pseudo graph that forces a check if a statement is already explicitly present in the result set and does not return implicit (inferred) versions of the same triple.
  • onto:merge - specifies that for the given triple pattern merge join should be used. Should be used with a GRAPH clause, rather than FROM. Merge join is the process of intersecting the current triple pattern with the partial result set which has been already accumulated. They are suitable when there are different collections sharing one or more variables with collection sizes that are relatively equivalent.
  • onto:hash - specifies that for the given triple pattern hash join should be used. Should be used with a GRAPH clause, rather than FROM. It performs an intersection between two sets of results by utilizing a hash table.
  • onto:explain - a pseudo graph that returns the query optimization plan.
  • onto:commitStatistics - if enabled, logs commit statistics every 30 seconds.
  • sys:statistics - a pseudo graph that forces the usage of the repository statistics in COUNT queries, instead of properly counting the results when the WHERE clause consists of only one statement pattern. This speeds up the counting operation for simple queries, but it can produce wrong counts where results are manipulated, for example, by owl:sameAs expansion.
  • onto:retain-bind-position - Doesn’t allow BIND to move freely. Its position is preserved as the original one, relative to the vars which were before it and the vars which were after it.

System predicates

System predicates are used to change the way in which the repository behaves. An example of system predicate usage would be:

PREFIX sys: <http://www.ontotext.com/owlim/system#>

INSERT DATA {
  _:b sys:addRuleset "owl-horst-optimized" .
  _:b sys:defaultRuleset "owl-horst-optimized" .
  _:b sys:reinfer _:b .
}
  • sys:schemaTransaction - allows for axiom insertion and removal, changing the ruleset.
  • sys:reinfer - forces full inference recomputation.
  • sys:turnInferenceOn - switches inferences on.
  • sys:turnInferenceOff - disables inference. This will not remove previously inferred statements.
  • sys:addRuleset - adds a ruleset.
  • sys:removeRuleset - removes a ruleset.
  • sys:defaultRuleset - refers to the default ruleset. Can be used to fetch it or change it.
  • sys:currentRuleset - refers to the current ruleset. Can be used to fetch it or change it.
  • sys:listRulesets - lists the currently installed rulesets.
  • sys:renameRuleset - renames a ruleset.
  • sys:exploreRuleset - retrieves a ruleset’s text, if any.
  • sys:consistencyCheckAgainstRuleset - checks data consistency against a given ruleset.
  • onto:replaceGraph - Sets a replacement graph. The content of that graph will be replaced with the incoming update. Multiple graphs may be provided by multiple calls with this predicate.
  • onto:replaceGraphPrefix - Sets a prefix for replacement graphs. All graphs whose IRIs start with the prefix will be replaced with the incoming update. Multiple prefixes may be provided by multiple calls with this predicate.