On a project I'm working on I'm starting to get the SOQL maximum query limit. Of course, I can use the debug logs to view all the queries to investigate. But that would be time consuming and difficult. What are some general best practices to reduce the query count? And if that doesn't work for me; what are some other options to solve this (like using @future
)?
-
when u mean query limit is it number of rows/character limit ?– RaoCommented Jan 11, 2013 at 8:18
-
Max no of soql queries I reckon– techtrekkerCommented Jan 11, 2013 at 8:19
-
yeah, the maximum of 100 queries per request– user254875486Commented Jan 11, 2013 at 8:22
-
1We'd need to see your code to see what is going wrong. My guess is, that you're doing soql queries within an iteration, this should be avoided always, have a look at: salesforce.stackexchange.com/questions/5633/…– Samuel De RyckeCommented Jan 11, 2013 at 8:35
-
1doing insert or update doesnt count in SOQL Query limit, it is a separate limit (No. of DML Operations). Generally these are the SELECT statements you are writing in your code. if they are in for loops you get this. Try using SET of Ids or where clauses to SELECT records– logontokartikCommented Jan 11, 2013 at 15:04
|
Show 1 more comment
1 Answer
Per your comment on the question about performing insert and update operations in a loop, it appears that reading and implementing SalesForce's "Best Practices" in your Apex DML operations would be the best start.
Apex Code & DML Best Practices
With special attention paid to items 2 and 4. Though the examples are written within triggers, these best practices should be adhered to everywhere in your codebase.