You need to sign in to do that
Don't have an account?

Optimize SOQL Query
Hi people, i need help:
I have map of list and that map it's very big, for every key i have list and i execute query for that list.
Thanks.
I have map of list and that map it's very big, for every key i have list and i execute query for that list.
Map<String,List<String>> map = new Map<string,List<String>>(); for(String key : map.keySet()){ List<Sobject> lsit = [SELECT Id, Name, Code FROM Sobject WHERE Name in map.get(key)] ; }How i can optimize this, if have way for execute in one query all that, how i can execute multiple list in query? This is important for me!
Thanks.
You need avoid soql for loop. See code below
As a common practice, if your question is answered, please choose 1 best answer.
But you can give every answer a thumb up if that answer is helpful to you.
Thanks,
Alex
Thanks
You can use the below code to avoid SOQL in loop.
Please change your code according to the below script : Let me know if there is any issue.
Thanks,
Abhishek