UUID 사용 → 닉네임 중복 최소화, 인덱스 효율 ↑
for (int i = 0; i < 1000000; i++) {
User user = new User(
"test" + i + "@email.com",
"123123" + i,
"유저" + UUID.randomUUID(),
UserRole.USER
);
}
- AOP를 활용하여
@GetMapping 메서드 기준 응답 속도 측정
@Aspect
@Component
@Slf4j
public class PerformanceAspect {
@Around("@annotation(org.springframework.web.bind.annotation.GetMapping)")
public Object logExecutionTime(ProceedingJoinPoint pjp) throws Throwable {
long start = System.nanoTime();
Object result = pjp.proceed();
long ms = (System.nanoTime() - start) / 1_000_000;
log.info("{} executed in {} ms", pjp.getSignature(), ms);
return result;
}
}

@Table(name = "users", indexes = @Index(name = "idx_users_nickname", columnList = "nickname"))

| 구분 |
평균 속도 |
속도 개선 |
| 인덱스 적용 전 |
570ms |
baseline |
| 인덱스 적용 후 |
6.6ms |
86배 개선 (98.8%) |