GraphDB System Statements

What’s in this document?

System statements are used as SPARQL pragmas specific to GraphDB. They are ways to alter the behavior 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 <https://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
}

System graph

Description

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 behavior 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

Does not allow BIND to move freely. Its position is preserved as the original one, relative to the vars that were before it and the ones that 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 {
  [] sys:addRuleset "owl-horst-optimized" .
  [] sys:defaultRuleset "owl-horst-optimized" .
  [] sys:reinfer [] .
}

System predicate

Description

sys:schemaTransaction

Allows for axiom insertion and removal, changing the ruleset.

sys:reinfer

Forces full inference re-computation.

sys:turnInferenceOn

Enables inferences.

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.