we have big problems with query performance in ObjectDB, this is our code. Any help would be appreciated.
First version of query gives result in 50ms for first 40 records from database but second version which queries 40+ records gives 19 seconds. We pinpointed that from he 53 record performances degrades significantly. On other queries threshold is different, possible due the size of the results (probably related to the number of related objects)
First version of code.
EntityManagerFactory emf = Persistence.createEntityManagerFactory("objectdb://10.10.10.14/E_POLICIJA.odb;user=admin;password=admin"); //$NON-NLS-1$
em = emf.createEntityManager();
long startTime;
long endTime;
startTime = System.currentTimeMillis();
int i = 0;
while(i < 40){
TypedQuery<AktImpl> queryAkt =
em.createQuery("SELECT e FROM AktImpl e", AktImpl.class);
queryAkt.setFirstResult(i);
queryAkt.setMaxResults(20);
queryAkt.getResultList();
i += 20;
}
endTime = System.currentTimeMillis();
System.out.println((endTime - startTime));
}
Second version of code
EntityManagerFactory emf =
Persistence.createEntityManagerFactory("objectdb://10.10.10.14/E_POLICIJA.odb;user=admin;password=admin"); //$NON-NLS-1$
em = emf.createEntityManager();
long startTime;
long endTime;
startTime = System.currentTimeMillis();
int i = 0;
while(i < 60){
TypedQuery<AktImpl> queryAkt =
em.createQuery("SELECT e FROM AktImpl e", AktImpl.class);
queryAkt.setFirstResult(i);
queryAkt.setMaxResults(20);
queryAkt.getResultList();
i += 20;
}
endTime = System.currentTimeMillis();
System.out.println((endTime - startTime));
}
Thanks for any help