SAP / olingo-jpa-processor-v4

The JPA Processor fills the gap between Olingo V4 and the database, by providing a mapping between JPA metadata and OData metadata, generating queries and supporting the entity manipulations.
Apache License 2.0
122 stars 76 forks source link

Reduce unnecessary joins for ElementCollections of Embeddable entities. #158

Closed DimitarPetrov closed 39 minutes ago

DimitarPetrov commented 2 years ago

Currently, when a query for element collections of embeddable entities is created, the whole chain of joins from the root entity to the embedded entity is made.

For example if we have the following relation: ent1->ent2->ent3->ent4->embeddableEntity

The joins that were create before for the query was: ent1, ent2, ent3, ent4, embeddableEntity

However, the information from ent1, ent2 and ent3 is not needed and the joins can be ommited.

The joins now looks like this: ent4, embeddableEntity

DimitarPetrov commented 1 year ago

Fair point! Actually, it is a pros and cons situation here.

In our case the tables in the chain are DB-heavy views and joining them on each query makes them pretty slow. However, with this fix in some cases, unnecessary data will reach the application which would be much slower to filter out.

Probably the best solution would be to check from the chain of parent-child relations which one is the first with some kind of filter - in this case, Organization is filtered by ID = 1 and start the joins from there.

However, I am lacking knowledge of the code to do this as a contribution.

wog48 commented 39 minutes ago

Pull request is outdated and therefore closed