I have the following pojo which maps a db row entry:
public class Pojo{
//key
private String a;
private String b;
private String c;
//other columns
private String d;
private String e;
private String f;
//defining attributes on each field with capital letter (ex: a->A)
}
I create the following collection:
IndexedCollection<Pojo> cq = new ConcurrentIndexedCollection<Pojo>();
//...loading data in collection from DB...
cq.addIndex(NavigableIndex.onAttribute(Pojo.A)); //part of key in DB
cq.addIndex(NavigableIndex.onAttribute(Pojo.F)); //not part of key in DB
Finally I measure the performances of the following query against a 200k elements taken from the db (all the table):
Query<Pojo> query1 = and(equal(Pojo.A, par1),
equal(Pojo.F, par2));
Equivalent, of course, to:
select* where A=? and F=?
but it seems my index strategy, in which I define an index for each parameter of the query, is lacking something as my query just accellerates the processing by mere 7ms comparing to direct DB access. Having all the table in the memory I would expect some better performances...what am I doing wrong?