Query monitoring and termination

GraphDB allows you to monitor details about running queries or stop them as they run.

Query monitoring

GraphDB provides detailed statistics about executing queries or more accurately query result iterators. This is done through the SailIterationMonitor MBean, one for each repository instance. Each bean instance is named after the storage directory of the repository it relates to.

Package com.ontotext
MBean name SailIterationMonitor

The SailIterationMonitor Mbean has a single attribute TrackRecords, which is an array of objects with the following attributes:

Attribute Description
isRequestedToStop indicates if the query has been requested to terminate early (see below)
msLifeTime the lifetime of the iterator (in ms) between being created and reaching the CLOSED state
msSinceCreated the time (in ms) since the iterator was created
nNext the total number of invocations of next() for this iterator
nsAverageForOneNext the average time spent for one (has)Next calculation (in nanoseconds), i.e., nsTotalSpentInNext / nNext
nsTotalSpentInNext the cumulative time spent in (has)Next calculations (in nanoseconds)
state the current state of the iterator, values are: ACTIVE, IN_NEXT, IN_HAS_NEXT, IN_REMOVE, IN_CLOSE, CLOSED
trackId a unique ID for this iterator - if debug level is used to increase the detail of the GraphDB output, then this value is used to identify queries when logging the query execution plan and optimisation information.

The collection of these objects grows for each executing/executed query, however, older objects in the CLOSED state expire and are removed from the collection as the query result iterators are garbage collected.

Terminating a query

Terminating queries can be done manually by running a JMX operation, using GraphDB Workbench or automatically - by configuring GraphDB to abort queries automatically after query-timeout has been reached.

Stopping queries using JMX

A single operation available with this MBean:

Operation Description
requestStop Request that a query terminates early; parameter: trackId of the query to stop.

This operation allows administrator to request that a query terminates earliest possible.

To terminate a query, execute the requestStop command with given trackId of the query. As a result:

  • The isRequestedToStop attribute is set to true.
  • The query terminates normally when hasNext() returns false.
  • Collected result so far will be returned by the interrupted query.

Stopping queries with GraphDB Workbench

To track and interrupt long running queries with the GraphDB Workbench, click Admin -> Query monitoring to go to the Query monitoring view.


If you are connected to a remote location, you need to have the JMX configured properly. See how in Managing locations.


To interrupt long running queries, click the Abort query button.

Automatically prevent long running queries

You can set a global query time-out period by adding a configuration parameter query-timeout. All queries will stop after this many seconds, where a default value of 0 indicates no limit.

Terminating a transaction

It is also possible to terminate a long committing update transaction. For example, when committing a ‘chain’ of many thousands of statements using some transitive property, the inferencer will attempt to materialise all possible combinations leading to hundreds of millions of inferred statements. In such a situation, you can abort the commit operation and rollback to the state the database had before the commit was attempted.

The following MBean is used:

Package com.ontotext
MBean name OwlimRepositoryManager

This MBean has no attributes:

Operation Description
abortTransactionCommit Request that the currently executing (lengthy) commit operation be terminated and rolled back.