Courseiva
Performance →hardMultiple Choice

SF-PD2 Performance Practice Question

A developer is optimizing a Visualforce page that displays a large dataset using a StandardSetController. The page currently loads slowly because it queries all records at once. The developer wants to implement pagination to improve performance. Which approach should be used?

⚠ Common exam trap

The trap here is assuming that using OFFSET or client-side pagination is equivalent to StandardSetController, when in fact StandardSetController is optimized for server-side pagination and avoids the performance pitfalls of large offsets.

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

✓

Use the StandardSetController's setPageSize method to limit the number of records per page and rely on its built-in pagination.

The StandardSetController is specifically designed to handle pagination efficiently. By setting the page size, it automatically limits the query to the records needed for the current page, reducing the initial load and memory footprint. Manual pagination with OFFSET or client-side pagination does not offer the same performance benefits and often introduces additional complexity or inefficiencies.

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 the @ReadOnly annotation on the controller to allow the page to query all records without hitting governor limits, then paginate client-side.

    Why it's wrong here

    @ReadOnly allows more query rows but does not improve pagination performance. Fetching all records at once still consumes memory and slows page load. Client-side pagination does not reduce the initial data transfer. The StandardSetController is the appropriate tool for server-side pagination.

  • ✗

    Use SOQL OFFSET to manually paginate the records in the controller, fetching only the records for the current page.

    Why it's wrong here

    SOQL OFFSET can be used for pagination, but it has performance implications for large offsets because the database must scan all preceding records. It also requires more custom code to manage page state. StandardSetController is optimized for this use case and should be preferred.

  • ✗

    Use a custom controller with a SOQL query that uses LIMIT and OFFSET, and implement pagination logic manually.

    Why it's wrong here

    While LIMIT and OFFSET can paginate, using OFFSET with large datasets causes performance degradation as the offset increases. A custom controller also requires manual handling of page navigation and state. StandardSetController provides built-in pagination without these drawbacks.

  • ✓

    Use the StandardSetController's setPageSize method to limit the number of records per page and rely on its built-in pagination.

    Why this is correct

    The StandardSetController is designed for pagination. By setting the page size, the controller automatically handles fetching only the records needed for the current page, reducing the initial query load. This is the most efficient way to implement pagination with minimal custom code.

About these practice questions

Courseiva writes every SF-PD2 question from scratch — 226 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or 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.