Courseiva
Performance →mediumMultiple Choice

SF-PD2 Performance Practice Question

A developer has built a Lightning Web Component that calls an Apex controller method to retrieve a list of Opportunities for a given Account. The SOQL query uses an indexed field on the Opportunity object, but the query still times out for Accounts with over 100,000 related Opportunities. The developer wants to improve performance by reducing the amount of data transferred and processed. Which approach should the developer take?

⚠ Common exam trap

The trap here is assuming that increasing timeout settings or using OFFSET can solve performance issues with large related lists, when in fact only efficient pagination techniques like keyset pagination address the root cause.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

Implement pagination using a custom cursor or Keyset pagination with the Id field.

Keyset pagination, also known as seek pagination, uses an indexed column (such as Id) to retrieve the next page of results without scanning previous rows. This method is highly efficient for large datasets because it avoids the performance degradation of OFFSET and limits the number of rows returned per call. By fetching only a small batch, it reduces both data transfer and processing, alleviating timeouts.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    Use SOQL OFFSET to paginate through the Opportunity records in chunks.

    Why it's wrong here

    OFFSET forces the database to scan and discard the specified number of rows before returning results, which becomes progressively slower as the offset grows. For an Account with 100,000 related Opportunities, using OFFSET would still require the database to process all preceding rows, leading to worse performance and potential timeouts. It does not reduce the amount of data transferred or processed efficiently.

  • ✗

    Increase the query timeout by setting a higher value in the Apex controller.

    Why it's wrong here

    Apex does not allow configuring query timeouts; governor limits are fixed. Attempting to adjust timeout settings is not possible and does not address the underlying performance problem. The timeout is a symptom of inefficient data retrieval, and without changing the query pattern, the issue persists regardless of any perceived timeout adjustment.

  • ✓

    Implement pagination using a custom cursor or Keyset pagination with the Id field.

    Why this is correct

    Keyset pagination uses a WHERE clause with the last seen Id (e.g., WHERE Id > :lastId ORDER BY Id LIMIT 200) to fetch the next set of records. This leverages the indexed Id field and avoids scanning skipped rows, making it efficient even for large datasets. It reduces data transfer and processing per request, directly addressing the timeout issue.

  • ✗

    Use a SOQL query with a FOR UPDATE clause to lock the records and speed up retrieval.

    Why it's wrong here

    FOR UPDATE is used to lock records for update in the same transaction, preventing other transactions from modifying them. It does not improve query performance; in fact, it adds locking overhead and can cause contention. For read-only retrieval of many records, this clause is inappropriate and will not reduce data transfer or processing time.

About these practice questions

This SF-PD2 question is part of Courseiva's 226-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Salesforce exam blueprint

This SF-PD2 practice question is part of Courseiva's free Salesforce certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the SF-PD2 exam.