With the Lazy Querying no criteria evaluated at all. Instead an iterator is created against the best index found. Further query processing, including all index processing, will happen when the application iterates through the result. This allows you to get the first query results almost immediately.
In addition to the very fast execution this method also ensures very small memory consumption. Because lazy queries do not need an intermediate representation as a set of IDs in memory. With this approach it does not have to cache a single object or ID. The memory consumption for a query is practically zero, no matter how large the result set is going to be.
There are some interesting effects appearing due to the fact that the objects are getting evaluated only on a request. It means that all the committed modifications from the other transactions and uncommitted modifications from the same transaction will be taken into account when delivering the result objects.
Query.execute()
will return very fast. First results can be made available to the application before the query is fully processed.ObjectSet
and changes each object in a way that it is placed at the end of the index, the same objects can be revisited over and over. ObjectSet
first and store all the objects to a temporary collection representation before changing objects and storing them back to db4o.
ObjectSet
will require the query processor to create a snapshot or to evaluate the query fully. An example of such a call is ObjectSet.size()
.Lazy mode can be an excellent choice for single transaction read use, to keep memory consumption as low as possible.