+ Start a Discussion
chikpeachikpea 

SOQL limitation

Is there any limitation on number of SOQL queries executed in a class? If so how much and whats the work around.
Edwin VijayEdwin Vijay

There are a number of limitations and a number of workarounds..

 

For ex: a soql query cannot return more than 1000 rows...  u can use a for loop to overcome this..

 

Even if you use a for loop, u can retrieve a maximum of 10000 rows..  Again to overcome this, you can use a action poller or @future annotation...

 

 

Hope this helps.. 

chikpeachikpea

I am getting this warning in test method -

 

Cumulative resource usage:

Resource usage for namespace: som
Number of SOQL queries: 58 out of 100 ******* CLOSE TO LIMIT

 

How to deal with this?

Edwin VijayEdwin Vijay

The number of queries that can be invoked in a apex class is 100... 

 

You need not worry about the warning as long as you do not hit the 100 limit... Usually queries placed inside a loop will cause them to be executed a number of times... Make sure that your class at any point of time does not hit the 100 limit..

 

Also, are you writing queries in your test method.. If so avoid them,,