Skip to content
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

검색 쿼리 개선 #703

Merged
merged 11 commits into from
Sep 27, 2024
Merged

Conversation

jminkkk
Copy link
Contributor

@jminkkk jminkkk commented Sep 26, 2024

⚡️ 관련 이슈

close #673

📍주요 변경 사항

  1. fetch join을 사용하여 N + 1 해결
  2. 템플릿 별 태그 조회 로직 변경
  3. 템플릿별 썸네일 조회 로직 변경

@jminkkk jminkkk added refactor 요구사항이 바뀌지 않은 변경사항 BE 백엔드 labels Sep 26, 2024
@jminkkk jminkkk added this to the 5차 스프린트🍗 milestone Sep 26, 2024
@jminkkk jminkkk self-assigned this Sep 26, 2024
Copy link
Contributor

@kyum-q kyum-q left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

몰리 수고했어요 ~
추후 개선 사항으로 코멘트 달아뒀습니다 ~
나중에 개선해봐요 ~

Comment on lines +55 to +59
public List<Tag> findAllByTemplateId(Long templateId) {
return templateTagRepository.findAllByTemplateId(templateId).stream()
.map(TemplateTag::getTag)
.toList();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

나중에 Tag 를 받도록 변경하면 좋을 것 같아욧 ~

Comment on lines +42 to +43
root.fetch("category", JoinType.LEFT);
root.fetch("member", JoinType.LEFT);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

추후 상수화 해요 ~

Comment on lines +30 to +31
List<Long> templateIds = templates.stream()
.map(Template::getId)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

추후 id만 받도록 코드 개선하면 커버링 인덱스를 이용할 수 있을 것 같아요 ~

Copy link
Contributor

@zangsu zangsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

}

public List<TemplateTag> getAllTemplateTagsByTemplates(List<Template> templates) {
List<Long> templateIds = templates.stream().map(Template::getId).toList();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
List<Long> templateIds = templates.stream().map(Template::getId).toList();
List<Long> templateIds = templates.stream()
.map(Template::getId)
.toList();

Copy link
Contributor

@zeus6768 zeus6768 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

개선될 부분 코멘트 남겼어요 ~!

@@ -14,6 +14,8 @@ public interface ThumbnailRepository {

List<Thumbnail> findAll();

List<Thumbnail> findAllByTemplateIn(List<Long> templateIds);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
List<Thumbnail> findAllByTemplateIn(List<Long> templateIds);
List<Thumbnail> findAllByTemplateIdsIn(List<Long> templateIds);

return new FindAllTemplatesResponse(
page.getTotalPages(),
page.getTotalElements(),
findAllTemplateByResponse);
}

private List<FindAllTemplateItemResponse> getFindAllTemplateItemResponses(List<Template> templates, LikedChecker likedChecker) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private List<FindAllTemplateItemResponse> getFindAllTemplateItemResponses(List<Template> templates, LikedChecker likedChecker) {
private List<FindAllTemplateItemResponse> findAllTemplateItemResponses(List<Template> templates, LikedChecker likedChecker) {

Copy link
Contributor

@HoeSeong123 HoeSeong123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨어요~~

@@ -52,6 +52,17 @@ public List<Tag> findAllByTemplate(Template template) {
.toList();
}

public List<Tag> findAllByTemplateId(Long templateId) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

사용되지 않는 메소드인 것 같네요.

@kyum-q kyum-q merged commit 5d40e4c into dev/be Sep 27, 2024
6 checks passed
@kyum-q kyum-q deleted the refactor/673-performance-template-search branch September 27, 2024 01:44
@jminkkk jminkkk changed the title 검색 성능 개선 검색 쿼리 개선 Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BE 백엔드 refactor 요구사항이 바뀌지 않은 변경사항
Projects
Status: Weekend Done
Development

Successfully merging this pull request may close these issues.

5 participants