Though Native Query API discussed in the previous paragraph is simple and straightforward, the real challenge is to provide a performant solution.
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.
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.
For more information see Native Query Optimization.