---
title: Avoid using size() in SOQL queries.xg
description: "**Impact area** Performance **Severity** high **Affected element** Apex Class ## Rule ID **SF-AVOID-SIZE-IN-SOQL** ## Impact Load large collections with SOQL in order to get total count using size() increase memory usage doing a negative impact in performance. ## Remediation Use…"
url: "https://community-staging.qualityclouds.com/qcdocs/qcr/rules/avoid-using-size-in-soql-queries-xg/"
updated: "2025-03-21"
category: Rules
---

# Avoid using size() in SOQL queries.xg

**Impact area**

Performance

**Severity**

high

**Affected element**

Apex Class

## Rule ID

**SF-AVOID-SIZE-IN-SOQL**

## Impact

Load large collections with SOQL in order to get total count using size() increase memory usage doing a negative impact in performance.

## Remediation

Use count() SOQL function in your query instead size() method in SOQL output list.

**Time to fix**

15 min
