February 6, 2018

How to avoid or reduce SOQLs in Salesforce?

1. Do not use SOQL inside the for a loop.

2. User UserInfo wherever possible - http://www.infallibletechie.com/2016/01/how-to-get-username-of-user-using-apex.html.

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 - http://www.infallibletechie.com/2014/05/how-to-avoid-recursive-trigger-in.html.

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

7. Use schema instead of the query to get record type, etc - http://www.infallibletechie.com/2014/03/how-to-get-recordtypeid-using-record.html.

No comments:

Post a Comment