Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

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)?

share|improve this question
    
when u mean query limit is it number of rows/character limit ? –  rao Jan 11 '13 at 8:18
    
Max no of soql queries I reckon –  techtrekker Jan 11 '13 at 8:19
    
yeah, the maximum of 100 queries per request –  Lex Jan 11 '13 at 8:22
1  
We'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 Rycke Jan 11 '13 at 8:35
1  
doing 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 –  logontokartik Jan 11 '13 at 15:04
show 1 more comment

1 Answer

up vote 4 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.