You are here: Advanced Features > Runtime Statistics > Monitoring Queries

Monitoring Queries

You can monitor queries to find out more about the runtime behavior of your application.

Configure the Query Monitoring Support

First you need to add the monitoring support to the db4o configuration. There are two separate items. The QueryMonitoringSupport will monitor the very basic query operations. The NativeQueryMonitoringSupport adds additional statistics about native queries.

configuration.common().add(new QueryMonitoringSupport());
configuration.common().add(new NativeQueryMonitoringSupport());
QueryMonitoring.java: Add query monitoring

The Query Statistics

AverageQueryExecutionTime : Tells you how long on average a query takes to execute. Of course this heavily depends on the complexity of the queries. However if this number is high, you maybe should improve you query-performance. For example by adding additional indexes. See "Indexing"

ClassIndexScansPerSecond: Tells you the number of queries which required to scan through all objects. This means that a query couldn't use a field index and therefore required to go through all objects. This is of course slow. You should try to keep this number low by adding the right indexes on fields. See "Indexing"

QueriesPerSecond: Tells you how many queries run per second.

Loaded From Class Index Notifications: The query statistics can notify you every time a query used the class-index and couldn't utilize a field index. You should try to avoid loading by class index by adding the right indexes on fields. See "Indexing"

The Native Query Statistics

NativeQueriesPerSecond: Tells you how many native queries per second run.

UnoptimizedNativeQueriesPerSecond: Tells you how many unoptimized native queries run per second. Such queries need to instantiate all objects which is a slow operation. If this number is high, you should try to simplify your queries.

Native Query Not Optimized Notifications: The native query statistics can notify you every time a query couldn't be optimized. You should try to avoid such queries. Try to simplify the native query or fall back to SODA-queries.