apex – Too many soql rows :101 for SOQL query on user object

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()];
system.debug(us.lastname);

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?

Read more here: Source link