---
title: Avoid Operation With High Cost In Loop
description: "Impact Area Performance Severity Medium Affected Element Apex Class ## Rule ID SF-AVOID-OPERATION-WITH-HIGH-COST-IN-LOOP ## Impact Repeated calls to such methods inside loops can significantly slow down application performance, especially in large organizations. ## Remediation Extract such method calls outside the…"
url: "https://community-staging.qualityclouds.com/qcdocs/qc/pmd-rules/avoid-operation-with-high-cost-in-loop/"
updated: "2025-03-21"
category: PMD Rules
---

# Avoid Operation With High Cost In Loop

Impact Area

Performance

Severity

Medium

Affected Element

Apex Class

## Rule ID

SF-AVOID-OPERATION-WITH-HIGH-COST-IN-LOOP

## Impact

 Repeated calls to such methods inside loops can significantly slow down application performance, especially in large organizations.

## Remediation

 Extract such method calls outside the loop and execute them only once to optimize performance.

**Time to fix**

30 min
