perf(account): 내역 목록 태그 조회 N+1 → 배치 단일 쿼리로 개선

list() 에서 항목마다 findTagNamesByEntryId() 를 개별 호출하던 N+1 을
findTagsByEntryIds() 배치 쿼리 1회로 대체.
항목 수가 많을 때 타임아웃/과부하 방지.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
ByungCheol
2026-07-02 01:47:08 +09:00
parent 947c7a1f68
commit 190fbe835f
3 changed files with 28 additions and 3 deletions
@@ -234,4 +234,16 @@
ORDER BY t.name
</select>
<!-- 복수 항목의 태그를 한 번에 조회 — {entry_id, tag_name} 행 반환 -->
<select id="findTagsByEntryIds" resultType="map">
SELECT aet.entry_id AS entryId, t.name AS tagName
FROM account_tag t
JOIN account_entry_tag aet ON aet.tag_id = t.id
WHERE aet.entry_id IN
<foreach item="id" collection="entryIds" open="(" separator="," close=")">
#{id}
</foreach>
ORDER BY aet.entry_id, t.name
</select>
</mapper>