How to avoid or reduce SOQLs in Salesforce?

1. Do not use SOQL inside the for loop.

2. User UserInfo wherever possible -

3. Use Custom Settings for hard coding Report Folder or Dashboard Folder ids, Email Templates ids, Public Group ids, Field ids, etc.

4. Use @future methods or queueable interface.

5. Avoid triggers from firing again and again -

6. Use trigger instead of workflow rules and process builders since they are not bulkified.

7. Use schema instead of query to get record type, etc -


No comments:

Post a Comment