db4o open source object database
db4o :: Java Product News Blog

Syndicate This

Monday, October 31, 2005

db4o 5.0 dev build featuring optimized native queries

A first development build of db4o 5.0 is available for download. It includes a first optimized implementation of native queries.

Native queries provide the simplest syntax possible to express code that is to be run against all instances of a class (an extent) from within a query. db4o analyzes .NET IL code or Java byte code of native query expressions and runs queries with maximum performance against indexes and without instantiating the actual objects of the extent.

The following syntax example of a native query demonstrates type safety and calling properties / getter methods:

C#
------------
IList <Cat> cats = db.Query <Cat> (delegate (Cat cat) {
return cat.Father.Father.FirstName == "Occam"
|| cat.Father.FirstName == "Occam"
&& cat.Age > 3;
});



Java
------------
List <Cat> cats = db.query(new Predicate <Cat>() {
public boolean match(Cat cat) {
return cat.getFather().getFather().getFirstName().equals("Occam")
|| cat.getFather().getFirstName().equals("Occam")
&& cat.getAge() > 3;
}
});



At this point in time the db4o native query optimization processor already "understands" most queries that could have also been expressed with the SODA API, but it is not perfect yet.

It will be an ongoing task to teach the native query optimizer more and more C# and Java syntax so it will eventually provide the maximum performance possible for any querying code.

Our first optimizer implementations employ the third-party libraries Cecil (.NET) and BLOAT (Java). Many thanks to the maintainers!