Optimizing Native Queries

Advantage

Optimized Native Queries allow to achieve considerable performance improvements.

Effect

Native Queries allow to express a database query in a native object-oriented language. This solution is elegant and straightforward as no mixture of concepts (object and relational) occurs. However, the challenge is to make this solution performant.

If the NQ code is run as is, it requires instantiation of all the members of a class. This is very slow in most cases. In order to improve the performance a special optimizer is used by db4o. The idea of the optimization is to analyze the code in a Native Query and provide an alternative in a database query language. This can be done in runtime or build time.

For detailed information about optimization strategies, please, see Native Query Optimization.

Alternate Strategies 

Obviously, optimization is not possible in cases, when a native query does not have a database query alternative. To reveal those cases db4o Diagnostic system should be used.