You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
현재 템플릿 엔티티에 @Fomula를 통해 좋아요 갯수를 가져오고 있습니다.
결국 매 템플릿 조회마다 좋아요 테이블에 조인하여 count 연산을 하여 가지고 오게 됩니다.
좋아요 갯수가 커질수록 조인으로 인한 오버헤드가 커지기 때문에 템플릿 당 좋아요 갯수를 저장하도록 반정규화합니다.
TO-BE
템플릿 조회 시 이미 연산된 좋아요 카운트를 조회만 하면되도록 변경합니다.
동시에 예상되는 데이터 정합성에 대한 문제도 고민이 필요할듯합니다.
📌 어떤 기능을 리팩터링 하나요?
AS-IS
현재 템플릿 엔티티에
@Fomula
를 통해 좋아요 갯수를 가져오고 있습니다.결국 매 템플릿 조회마다 좋아요 테이블에 조인하여 count 연산을 하여 가지고 오게 됩니다.
좋아요 갯수가 커질수록 조인으로 인한 오버헤드가 커지기 때문에 템플릿 당 좋아요 갯수를 저장하도록 반정규화합니다.
TO-BE
템플릿 조회 시 이미 연산된 좋아요 카운트를 조회만 하면되도록 변경합니다.
동시에 예상되는 데이터 정합성에 대한 문제도 고민이 필요할듯합니다.
⏳ 예상 소요 시간
🔍 참고할만한 자료(선택)
좋아요 개수 조회 최적화하기
The text was updated successfully, but these errors were encountered: