Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
exam questions

Exam Certified Platform Developer II All Questions

View all questions & answers for the Certified Platform Developer II exam

Exam Certified Platform Developer II topic 1 question 58 discussion

Actual exam question from Salesforce's Certified Platform Developer II
Question #: 58
Topic #: 1
[All Certified Platform Developer II Questions]

Part of a custom Lightning Component displays the total number of Opportunities in the org, which is in the millions. The Lightning Component uses an Apex
Controller to get the data it needs.
What is the optimal way for a developer to get the total number of Opportunities for the Lightning Component?

  • A. Apex Batch job that counts the number of Opportunity records
  • B. SUM() SOQL aggregate query on the Opportunity object
  • C. SOQL for loop that counts the number of Opportunities records
  • D. COUNT() SOQL aggregate query on the Opportunity object
Show Suggested Answer Hide Answer
Suggested Answer: D 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
nibbio
Highly Voted 2 years, 11 months ago
SELECT COUNT() is the correct answer (D). Tested with a Case object containing 7 millions of records
upvoted 11 times
...
rodmfpwc
Highly Voted 3 years, 7 months ago
Aditya97 I think D. COUNT() could be right because: Queries that include aggregate functions are still subject to the limit on total number of query rows i.e 50,000. All aggregate functions other than COUNT() or COUNT(fieldname) include each row used by the aggregation as a query row for the purposes of limit tracking. For COUNT() or COUNT(fieldname) queries, limits are counted as one query row, unless the query contains a GROUP BY clause, in which case one query row per grouping is consumed.
upvoted 7 times
singhkar
3 years, 5 months ago
A is the correct ans because the records are in millions not 50000
upvoted 1 times
...
...
beardAnt
Most Recent 1 month, 1 week ago
Selected Answer: C
Count is the answer
upvoted 1 times
...
FriedConsole2000
9 months ago
Selected Answer: D
Count should be used in an aggregate SOQL
upvoted 1 times
...
santo_aj
1 year, 6 months ago
Selected Answer: D
SELECT COUNT() is the correct answer (D).
upvoted 1 times
...
lorenac2
1 year, 10 months ago
The answer is D. Using the basic COUNT() function returns an integer, not an aggregate result, so there is even less code to write. Also, the limit is on the number of rows retrieved, not queried against. https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_count.htm https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_SOQL_agg_fns.htm
upvoted 1 times
...
OmShantiVeg
2 years, 3 months ago
Ans is d => https://help.salesforce.com/s/articleView?id=release-notes.rn_apex_soql_count_limits.htm&type=5&release=214
upvoted 2 times
...
Rob177
2 years, 9 months ago
Selected Answer: A
Should be A, as COUNT() hits the limits of 50k records. https://metillium.com/2016/05/soql-50000-record-limit-applies-with-count/
upvoted 1 times
ChiaSam
2 years, 4 months ago
it is no more applicable as now it is treated as just 1 row being returned.
upvoted 2 times
...
Jokei
11 months, 1 week ago
Wrong information!
upvoted 2 times
...
...
Sri_Vathsa
2 years, 11 months ago
D is the correct answer without any doubt. Count() only contributes as 1 SOQL query.
upvoted 2 times
...
ncore
2 years, 11 months ago
I also think D is correct according to this source https://help.salesforce.com/s/articleView?id=release-notes.rn_apex_soql_count_limits.htm&type=5&release=214
upvoted 3 times
...
Aditya97
3 years, 9 months ago
Correct answer should be A as there are millions of Opportunities and COUNT() will hit limit t 50000 records.
upvoted 3 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...