---
title: Avoid DML Statements Inside Loops
description: "**Impact area** Performance **Severity** High **Affected element** Apex Class ## Rule ID **SF-0017** ## Impact DML statements inside loops can cause you to hit the DML governor limit. ## Remediation  Try to batch up the data into a list and…"
url: "https://community-staging.qualityclouds.com/qcdocs/qc/pmd-rules/avoid-dml-statements-inside-loops/"
updated: "2025-03-21"
category: PMD Rules
---

# Avoid DML Statements Inside Loops

**Impact area**

Performance

**Severity**

High

**Affected element**

Apex Class

## Rule ID

**SF-0017**

## Impact

DML statements inside loops can cause you to hit the DML governor limit.

## Remediation

 Try to batch up the data into a list and invoke your DML once on that list of data outside the loop.

### Time to fix

60 min
