Home » Support » Forum » First persist takes long time

First persist takes long time


We detected that the first Persist() of an entity take much longer than all subsequent calls.

We have a small example (see Appendix) which outputs the following times:

First transaction with persist of MyEntity   Transaction: 91   Persist: 84

First persist of FirstEntity   Transaction: 16   Persist: 14
Second persist of FirstEntity   Transaction: 1   Persist: 0

First persist of SecondEntity   Transaction: 117    Persist: 103
Second persist of SecondEntity   Transaction: 2   Persist: 0

Here you can see well that it will take longer if the entity is more complex.

Important setting in objectDB.conf for the example:

<cascade-persist always="auto" on-persist="true" on-commit="true" />

Could you explain the long time for first persist?


Some operations are only required for a new entity type (e.g. analyzing and persisting the type schema, allocating storage space, etc.) so this is expected.

If you are concerned because you have to repeat these initializations for many odb files, consider registering all the types in an empty odb file (e.g. by accessing the types using the JPA Metamodel API) and then you can duplicate that empty odb file (with the types) when necessary.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)

Post Reply

To post a reply and/or subscribe to update notifications - please login