Skip to main content
Boundaries on SOQL statements

Ensure all SOQL statements are either bound by either a LIMIT or by a WHERE clause.

Lorenzo Frattini avatar
Written by Lorenzo Frattini
Updated over 6 years ago

Rationale

Salesforce limits the  maximum number of rows that can be returned by a SOQL query to 50,000 records. If such number is exceeded, a runtime exception is thrown. As a best practice developers should always use either a WHERE or a LIMIT clause, so  that the maximum number of records retrieved is capped.

Scope

  • Apex classes and triggers

Exclusions 

  • This rule is not applied to test methods

Did this answer your question?