Home » Support » Forum » Performance question

Performance question

#1

Hello,

suppose you have an entity that holds a reference to another entity which in turn contains e.g. a date field you want to query for. Is there an improvement in performance if I create a "mirror" date field in the original entity, removing the need to traverse through the referenced other entity?

So, querying for "all objects with object.otherobject.date > 1.1.1980" is slower than "all objects with object.date > 1.1.1980"? Or doesn't this matter, using proper indexing?

Thanks, Benjamin

 

#2

> So, querying for "all objects with object.otherobject.date > 1.1.1980" is slower than "all objects with object.date > 1.1.1980"? Or doesn't this matter, using proper indexing?

Yes. Mirroring the date will improve performance (unless otherobject is embedded object rather than an entity), because the query will have to handle only one entity classes instead of two.

But duplicating data is usually not recommended unless there is no other solution and you really need this performance improvement.

If you keep the date only in the second entity class - at least define 2 indexes: one on the date field and the other on the reference field to the other object.

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

Post Reply

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