spring-projects / spring-projects/spring-data-rest

SDR queries all associations even if they are not in the requested projection [DATAREST-1089]

Open
#1,454 8 comments 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 31, 2020.

status: feedback-provided type: enhancement
Dominant language
Java
Stars
958
Forks
568
PR merge metrics
No merged PRs in 30d

Description

Josh Wand opened DATAREST-1089 and commented

I have noticed that even when specifying a lightweight projection, SDR nonetheless queries every single association on my entity, without checking to see if it's in the projection. This results in many extra DB queries that are dramatically slowing down my application.

I've traced the code to this line:

https://github.com/spring-projects/spring-data-rest/blob/master/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/EmbeddedResourcesAssembler.java#L77

There are checks to see if the association is linkable, or if itself has an excerpt projection, but not to see if the requested association is specified in the projection itself.

Can this check be added? This is a major performance issue.

(see also https://stackoverflow.com/questions/44379069/how-to-avoid-n1-queries-with-spring-data-rest-projections )


3 votes, 5 watchers

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.