Created
October 24, 2013 18:26
-
-
Save msrivastav13/7142462 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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