Hello again.
It's clear that I'm studying db4o's performance. I created a new topic cause this is a different problem.
The thing that makes me wonder is that the use of MemoryIoAdapter speed up the reads very few: without MemoryIoAdapter the reads take 4200 ms, while with MemoryIoAdapter, they take 3700 ms! The same little difference is present also when using a proper index (but now the time is about 50 ms).
- Is this a normal behavior for MemoryIoAdapter? I would expect a better performance when i put all my database in main memory.
- Another question: With MemoryIoAdapter Db4o can now be called "in-memory database". But is there a way to add durability, while still having the whole database in main memory (eg: making use of a log file)? This is a solution that is something like Prevayler that i think you know (at least Klaus Wuestefeld knows)!
Thanks.
public static void main(String[] args) {
new File(DATABASE_FILE).delete();
Configuration configuration = Db4o.newConfiguration();
MemoryIoAdapter memoryIoAdapter = new MemoryIoAdapter();
configuration.io(memoryIoAdapter);
// configuration.objectClass(Number.class).objectField("number").indexed(true);
ObjectContainer db = Db4o.openFile(configuration,DATABASE_FILE);
long start = System.currentTimeMillis();
for (int i = 0; i < 100000; i++) {
db.store(new Number(i));
}
System.out.println("time: " + (System.currentTimeMillis()-start));
db.commit();
System.out.println("size: " + db.queryByExample(new Number()).size());
start = System.currentTimeMillis();
for (int i = 0; i < 100; i++) {
if (!db.queryByExample(new Number(i)).hasNext())
System.out.println("Empty ObjectSet!");
}
System.out.println("time: " + (System.currentTimeMillis()-start));
db.close();
}