New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #1302 n+1 queries in owners #1303
Conversation
It's not a terrible idea, but maybe not really all that necessary (given that n=5). Anyway, if you would like to remove the otel stuff and squash and rebase to a single commit I will take another look. |
commit fd32ee7 Author: Tom Ekshtein <tekshteint@gmail.com> Date: Fri Sep 8 12:24:10 2023 -0700 Removed OTEL commit 33e2235 Author: Tom Ekshtein <tekshteint@gmail.com> Date: Mon Jul 24 11:24:02 2023 -0700 fixed dependencies commit 7fd676e Author: Tom Ekshtein <tekshteint@gmail.com> Date: Mon Jul 24 11:20:59 2023 -0700 removed old file commit 0e5db6f Author: Tom Ekshtein <tekshteint@gmail.com> Date: Mon Jul 24 11:20:00 2023 -0700 N+1 fixed only my changes are present, everything else is as made by Spring
Not a problem, sorry for the mess as I'm still new to Git but I hope that this should be more proper now. Branches squashed and merged, OTEL has been removed and only the fix remains. |
The changes to |
Ran mvn spring-javaformat:apply as shown from github's build failure
@dsyer Everything should be taken care of, thanks again for your patience with me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the commit message is different that the changes
How so? I don't believe I changed anything else aside from running the spring formatting maven command |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some more minor stuff to tweak.
@@ -34,6 +35,7 @@ | |||
import org.springframework.web.servlet.ModelAndView; | |||
|
|||
import jakarta.validation.Valid; | |||
import org.thymeleaf.util.StringUtils; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use Spring's StringUtils
.
model.addAttribute("currentPage", page); | ||
model.addAttribute("totalPages", paginated.getTotalPages()); | ||
model.addAttribute("totalItems", paginated.getTotalElements()); | ||
model.addAttribute("listOwners", listOwners); | ||
model.addAttribute("listOwners", paginated); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"listOwners" is now added twice?
id 'org.springframework.boot' version '3.1.1' | ||
id 'io.spring.dependency-management' version '1.1.0' | ||
id 'org.graalvm.buildtools.native' version '0.9.23' | ||
id 'java' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please get rid of whitespace changes (I don't think this file changed at all so you could just grab it from main).
I think we ran out of energy on this one. Assume not needed. |
Issue #1302
When using the parameterless GET request on the /owners endpoint as well as searching for an empty string on the webpage for owners, the petclinic application ends up creating N+1 queries. This is due to the following code:
OwnerController.processFindForm
This can be solved by adding a new query to the Owner Repository and updating the controller. These changes can be observed using digma.ai as I've left the necessary imports/dependencies for Open Telemetry as well.