I have an issue on running some functionality from the front end. while executing the user query, the system gives an error message Too Many SOQL rows:101.

I have checked the code, it is not inside the for loop.

User us = [SELECT Id,firstName,email,lastname FROM User WHERE Id =:UserInfo.getUserId()];

One solution is to run this code asynchronously and use the future method to return the user record but how?

I am stuck in returning the query result basically.

Any help in this part?

1 Answer 1


These limits are the effect of the execution across an entire transaction. Consider this simple code:

for(Integer i = 0; i < 100; i++) {
  Account a = [SELECT Id FROM Account LIMIT 1];
Account b = [SELECT Id FROM Account LIMIT 1];

Here, the system will throw an error when querying b, even though a used 100% of the governor limits.

You'll want to set up a profiling log file using TraceFlag, such as by setting up debugging, in order to find where your queries are going. This is, unfortunately, one of those limits that requires additional research, since the line of code that was "blamed" isn't always the culprit.

  • ...its good that u re here...and u re telling the right thing only but after debugging i found issue is there in this line itself.
    – SFDC LWC
    Dec 8, 2023 at 9:12
  • Have used recursive check to bypass it...let me test and see if it works or not.
    – SFDC LWC
    Dec 8, 2023 at 9:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .