Which action can a developer take to reduce the execution time of the - ProProfs Discuss
Topics-
Products +
     

Which action can a developer take to reduce the execution time of the following code?
List allaccounts = [select ID from account];list allcontacts = [select ID, accountid from contact];for (account a :allaccounts){ for (contact c:allcontacts){    if(c.accountid = a.ID){do work } }}



A. Use a map for allaccounts
B. Add a group by clause to the contact SOQL
C. Put the account loop inside the contact loop
D. Create an apex helper class for the SOQL

This question is part of Salesforce Platform Developer Coding Test! Trivia Quiz
Asked by Marcofrancesconuzzo, Last updated: Nov 08, 2019

+ AnswerRequest Answer
...

2 Answers

shilpaads

Shilpaads

Answered on Nov 08, 2019

A. Use a map for all accounts
 Reply

marcofrancesconuzzo

Marcofrancesconuzzo

Answered on Jul 28, 2019

Use a map for allaccounts
 Reply

Search for Google images
Select a recommended image
Upload from your computer
Search for Google images
Select a recommended image
Upload from your computer
Search for Google images
Select a recommended image
Upload from your computer

Email Sent
We have sent an email to your address "" with instructions to reset your password.