Skip to content

Instantly share code, notes, and snippets.

@msrivastav13
Created October 24, 2013 18:26
Show Gist options
  • Save msrivastav13/7142462 to your computer and use it in GitHub Desktop.
Save msrivastav13/7142462 to your computer and use it in GitHub Desktop.
List<Account> lstacc=[Select Id from Account limit 10000];
Set<Id> setIds=new Set<Id>();
for(Account a:lstacc){ //More CPU time for sure due to looping
setIds.add(a.id);
}
//Using Map query saves CPU time
//Fetching all account in map
Map<id,account> aMap = new Map<id,account>([Select Id,Name from Account limit 50000]);
//Creating list of accounts
List<account> accList = aMap.values() ;
//Creating set of ids
Set<id> accIds = aMap.keySet() ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment