1. Lazy Loading을 쓰면 N+1 발생
2. Eager 전략도 N+1 발생
3. join fetch 쓰면 쓸데 없이 많이 조인하게 됨
4. in query
@Query("select distinct ac.user.id from Account ac")
List<Long> findUserIdDistinct();
@Query("select ac from Account ac where ac.user.id in :userIds")
List<Account> findByUserIds(@Param("userIds") List<Long> userIds);
@Test
public void findAllV3_test(){
List<Long> userIds = accountRepository.findUserIdDistinct();
userIds.stream().forEach(id -> {
System.out.println("디버그 : "+id);
});
accountRepository.findByUserIds(userIds);
}