+ Concise, actionable review of the main bottleneck.
- The conditional security note slightly dilutes the focus.
a Code Review Expert. You are an experienced software developer with extensive knowledge in code analysis and improvement.
| Category | Development › Coding |
|---|---|
| Tags | ReviewingAnalyzingDeveloperCodeTemplate |
Act as a Code Review Expert. You are an experienced software developer with extensive knowledge in code analysis and improvement.
Your task is to review the code provided by the user, focusing on areas such as:
- Code quality and style
- Performance optimization
- Security vulnerabilities
- Compliance with best practices
You will:
- Provide detailed feedback and suggestions for improvement
- Highlight any potential issues or bugs
- Recommend best practices and optimizations
Rules:
- Ensure feedback is constructive and actionable
- Respect the language and framework provided by the user
${language} - Programming language of the code
${framework} - Framework (if applicable)
${focusArea:general} - Specific area to focus on (e.g., performance, security)This role prompt reviews user-provided code as an experienced developer. It asks the assistant to respect the given language and framework and provide constructive, actionable feedback.
ChatGPT has the best balance of accuracy and brevity. Gemini is more detailed but somewhat overstated and long, while [C] is missing.
+ Concise, actionable review of the main bottleneck.
- The conditional security note slightly dilutes the focus.
+ Thoroughly analyzes N+1 and full-table loading.
- Overlong, with an unsupported replica-routing claim.
| Criterion | ChatGPT | Gemini | Leader |
|---|---|---|---|
| Instruction following | 10 | 10 | Tie |
| Accuracy | 9 | 8 | ChatGPT +13% |
| Specificity | 9 | 10 | Gemini +11% |
| Structure | 9 | 9 | Tie |
| Right length | 10 | 7 | ChatGPT +43% |
Scored 1–10 by gpt-5.6-sol with model names hidden (2026-09-24). This is an AI review, not a measurement.
We gave three models the same input and copied their answers unedited. Each ran in its CLI (an agent harness), and answers in the ChatGPT or Claude apps or on the web may differ. Outputs are in Korean.
[Pasted material]
언어: Java, 프레임워크: Spring Boot, 집중 영역: 성능(performance)
```java
@GetMapping("/orders")
public List<OrderDto> getOrders() {
List<Order> orders = orderRepository.findAll();
List<OrderDto> result = new ArrayList<>();
for (Order o : orders) {
Customer c = customerRepository.findById(o.getCustomerId()).orElseThrow();
result.add(new OrderDto(o.getId(), c.getName(), o.getTotal()));
}
return result;
}
```주요 문제는 주문 수만큼 고객 조회가 반복되는 N+1 쿼리입니다.
for (Order o : orders) {
customerRepository.findById(o.getCustomerId());
}
주문이 1,000개면 최소 1번의 주문 조회와 1,000번의 고객 조회가 발생할 수 있어 성능이 크게 저하됩니다.
개선 방향은 다음과 같습니다.
Order와 Customer를 조인한 조회 사용orElseThrow()의 예외를 명시적으로 처리예를 들어 Spring Data JPA에서는 DTO projection을 사용할 수 있습니다.
public interface OrderRepository extends JpaRepository<Order, Long> {
@Query("""
select new com.example.api.OrderDto(
o.id,
c.name,
o.total
)
from Order o
join Customer c on c.id = o.customerId
order by o.id desc
""")
Page<OrderDto> findOrderDtos(Pageable pageable);
}
서비스와 컨트롤러는 다음처럼 분리할 수 있습니다.
@Service
@RequiredArgsConstructor
@Transactional(readOnly = true)
public class OrderService {
private final OrderRepository orderRepository;
public Page<OrderDto> getOrders(Pageable pageable) {
return orderRepository.findOrderDtos(pageable);
}
}
@GetMapping("/orders")
public Page<OrderDto> getOrders(
@PageableDefault(size = 50, sort = "id", direction = Sort.Direction.DESC)
Pageable pageable
) {
return orderService.getOrders(pageable);
}
추가로 확인할 사항입니다.
findAll()은 주문이 많아질수록 메모리를 과도하게 사용할 수 있습니다.orElseThrow()는 고객 데이터가 없을 때 기본 예외가 노출될 수 있으므로 도메인 예외와 적절한 HTTP 상태 코드로 변환하는 것이 좋습니다.customerId를 직접 보유하는 구조라면 조인 조건을 명확히 관리해야 합니다. 가능하다면 Order와 Customer의 JPA 연관관계 및 join fetch 또는 projection 사용을 검토할 수 있습니다.가장 우선순위가 높은 개선은 findById() 반복을 제거하고, 페이지 단위의 조인 기반 DTO 조회로 변경하는 것입니다.
| 12-Month AI and Computer Vision Roadmap for Defense Applications | |
| 2046 Puzzle Game Challenge | |
| 21st.dev component prompt | |
| 3D FACTORY | |
| 3D FPS Game |