Avoid using size() in SOQL queries.

Impact area

Performance

Severity

high

Affected element

Salesforce

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

What's here


Related content

Apex Page rules

Salesforce rules




Last modified on Nov 30, 2023